From 976b33d6e7a7f4031bf259a739e4575c673da2c1 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 13:52:03 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0video=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AskServiceImpl.java | 46 ++++++++++++------- .../src/main/resources/application-dev.yml | 4 +- .../src/main/resources/application-local.yml | 4 +- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index 8f4f17f6..4e1d8e59 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -13,14 +13,17 @@ import com.supervision.pojo.vo.TalkReqVO; import com.supervision.pojo.vo.TalkResultResVO; import com.supervision.service.*; import com.supervision.util.*; +import io.minio.MinioClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.util.List; import java.util.Optional; @@ -40,6 +43,11 @@ public class AskServiceImpl implements AskService { private final ConfigAncillaryItemService configAncillaryItemService; + private final FileResourceService fileResourceService; + + @Value("${defaultNoMatchId}") + private String defaultNoMatchId; + @Override public String receiveVoiceFile(MultipartFile file) { @@ -195,10 +203,7 @@ public class AskServiceImpl implements AskService { String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId()); // 如果rasa没有识别出来,则返回默认值 if (StrUtil.isBlank(rasaResult)) { - // TODO 这里应该返回视频流 - String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); - + downloadTalkVideo(defaultNoMatchId,response); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } TalkResultResVO talkResultResVO = new TalkResultResVO(); @@ -220,9 +225,7 @@ public class AskServiceImpl implements AskService { AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); if (ObjectUtil.isEmpty(library)) { log.info("{}:未从问题库中找到,回答未识别语句", rasaResult); - // TODO 这里应该返回视频 - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); - + downloadTalkVideo(defaultNoMatchId,response); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } else { AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) @@ -233,9 +236,7 @@ public class AskServiceImpl implements AskService { // 首先看看default里面是不是存在,如果存在,就从default里面去找 if (StrUtil.isNotEmpty(library.getDefaultAnswer())) { String resText = library.getDefaultAnswer(); - // TODO 这里应该返回视频 - - HumanUtil.textDriven(resText, roomId); + downloadTalkVideo(defaultNoMatchId,response); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText()); @@ -250,21 +251,19 @@ public class AskServiceImpl implements AskService { if (StrUtil.isNotEmpty(library.getDefaultAnswer())) { String resText = library.getDefaultAnswer(); log.info("{}:病历配置的回答:{}:为空不为空不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, askPatientAnswer.getId(), resText); - // TODO 这里应该返回视频 - HumanUtil.textDriven(resText, roomId); + // 这里返回视频 + downloadTalkVideo(library.getDefaultAnswerResourceId(), response); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); } else { log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult, askPatientAnswer.getId()); - // TODO 这里应该返回视频 - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); + downloadTalkVideo(defaultNoMatchId,response); } } else { String resText = askPatientAnswer.getAnswer(); log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText); - // TODO 这里应该返回视频 - HumanUtil.textDriven(resText, roomId); + downloadTalkVideo(askPatientAnswer.getAnswerResourceId(),response); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText); } @@ -275,7 +274,20 @@ public class AskServiceImpl implements AskService { talkResultResVO.setType(1); return talkResultResVO; -// IoUtil.copy(inputStream, response.getOutputStream()); +// // return null; } + + private void downloadTalkVideo(String fileId, HttpServletResponse response) { + FileResource fileResource = fileResourceService.getById(fileId); + if (ObjectUtil.isEmpty(fileResource)) { + throw new BusinessException("未找到回复视频"); + } + try (InputStream inputStream = MinioUtil.download(fileResource.getMinioId())) { + IoUtil.copy(inputStream, response.getOutputStream()); + } catch (Exception e) { + log.error("获取视频失败", e); + throw new BusinessException("未找到回复视频"); + } + } } diff --git a/virtual-patient-web/src/main/resources/application-dev.yml b/virtual-patient-web/src/main/resources/application-dev.yml index e83815c3..08c6b22f 100644 --- a/virtual-patient-web/src/main/resources/application-dev.yml +++ b/virtual-patient-web/src/main/resources/application-dev.yml @@ -82,4 +82,6 @@ human: ws: # nginx的wss地址(如果是wss的,那么带不带s都可以访问) nginx-ip: 192.168.10.138 - nginx-port: 443 \ No newline at end of file + nginx-port: 443 +# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID +defaultNoMatchId: 1 \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/application-local.yml b/virtual-patient-web/src/main/resources/application-local.yml index 31dca534..d4c0220e 100644 --- a/virtual-patient-web/src/main/resources/application-local.yml +++ b/virtual-patient-web/src/main/resources/application-local.yml @@ -83,4 +83,6 @@ human: ws: # nginx的wss地址(如果是wss的,那么带不带s都可以访问) nginx-ip: 192.168.10.138 - nginx-port: 443 \ No newline at end of file + nginx-port: 443 +# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID +defaultNoMatchId: 1 \ No newline at end of file From 686f378e4c255696bc0b2e5ab193fbae5bec0881 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 14:21:49 +0800 Subject: [PATCH 02/14] =?UTF-8?q?bugfix:=E5=A2=9E=E5=8A=A0=E9=82=AE?= =?UTF-8?q?=E7=BC=96=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ProcessMedicalMapper.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/virtual-patient-model/src/main/resources/mapper/ProcessMedicalMapper.xml b/virtual-patient-model/src/main/resources/mapper/ProcessMedicalMapper.xml index 8216bed5..ae92898e 100644 --- a/virtual-patient-model/src/main/resources/mapper/ProcessMedicalMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/ProcessMedicalMapper.xml @@ -57,6 +57,7 @@ mr.patient_marriage as patientMarriage, mr.native_place as nativePlace, mr.patient_phone as patientPhone, + mr.patient_postcode as patientPostcode, mr.patient_birthplace as patientBirthplace, mr.patient_habitation as patientHabitation, mr.patient_postcode as patientHabitation, From 37d84d10119289434412a462a875ab825f87043d Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 14:37:40 +0800 Subject: [PATCH 03/14] =?UTF-8?q?bugfix:=E5=A2=9E=E5=8A=A0=E9=82=AE?= =?UTF-8?q?=E7=BC=96=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/supervision/service/impl/AskPrimaryServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java index fde9c96d..9e8fd557 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.druid.sql.visitor.functions.If; import com.sun.media.sound.AiffFileReader; @@ -210,6 +211,9 @@ public class AskPrimaryServiceImpl implements AskPrimaryService { throw new BusinessException("电子病历未填写,请填写电子病例后诊毕"); } for (PrimaryConfirmReqVO reqVO : reqVOList) { + if (ObjectUtil.isEmpty(reqVO.getExcludeFlag()) && 0 != reqVO.getExcludeFlag() && 1 != reqVO.getExcludeFlag()) { + throw new BusinessException("是否排除不能为空或诊断不正确"); + } // 修改初步诊断是否被排除 diagnosisPrimaryService.lambdaUpdate().set(DiagnosisPrimary::getExcludeFlag, reqVO.getExcludeFlag()) .eq(DiagnosisPrimary::getId, reqVO.getPrimaryId()).update(); @@ -277,7 +281,7 @@ public class AskPrimaryServiceImpl implements AskPrimaryService { vo.setPrimaryDiseaseName(""); } }) - .collect(Collectors.toMap(DiagnosisPrimaryVO::getId, DiagnosisPrimaryVO::getPrimaryDiseaseName)); + .collect(Collectors.toMap(DiagnosisPrimaryVO::getId, DiagnosisPrimaryVO::getPrimaryDiseaseName)); // 查询诊疗记录对应的所有检查记录 List relationList = diagnosisPrimaryRelationService.lambdaQuery().eq(DiagnosisPrimaryRelation::getProcessId, processId).list(); // 根据relationId进行分组 From 9c08c8cdce9d553311881fcc209116c0df4e0355 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 14:46:43 +0800 Subject: [PATCH 04/14] =?UTF-8?q?bugfix:=E4=BC=98=E5=8C=96=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E7=BB=93=E6=9E=9C=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/supervision/vo/ask/AskPhysicalHistoryResVO.java | 3 +++ .../com/supervision/service/impl/AskPhysicalServiceImpl.java | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskPhysicalHistoryResVO.java b/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskPhysicalHistoryResVO.java index bfb314cc..81ded927 100644 --- a/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskPhysicalHistoryResVO.java +++ b/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskPhysicalHistoryResVO.java @@ -31,6 +31,9 @@ public class AskPhysicalHistoryResVO { @ApiModelProperty("体格检查结果") private String result; + @ApiModelProperty("关联的初步诊断的疾病名称") + private String diseaseName; + @ApiModelProperty("检查时间") private LocalDateTime createTime; } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPhysicalServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPhysicalServiceImpl.java index 40316fd9..d3189c19 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPhysicalServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPhysicalServiceImpl.java @@ -124,9 +124,8 @@ public class AskPhysicalServiceImpl implements AskPhysicalService { diseaseNameList.add(diseaseName); } } - node.setResult(StrUtil.join(";", diseaseNameList)); + node.setDiseaseName(StrUtil.join(";", diseaseNameList)); } - return res; } From 8ba94d592ecede7eb4ec6e85543d36ba6eedac20 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 14:47:39 +0800 Subject: [PATCH 05/14] =?UTF-8?q?bugfix:=E4=BC=98=E5=8C=96=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E7=BB=93=E6=9E=9C=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/supervision/service/impl/AskPrimaryServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java index 9e8fd557..3f5e46fe 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java @@ -6,8 +6,6 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.druid.sql.visitor.functions.If; -import com.sun.media.sound.AiffFileReader; import com.supervision.exception.BusinessException; import com.supervision.model.Process; import com.supervision.model.*; From f5f91244fcf156320120302f71413c1b1572d53c Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 14:59:24 +0800 Subject: [PATCH 06/14] =?UTF-8?q?bugfix:=E4=BF=AE=E5=A4=8D=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=90=8D=E7=A7=B0=E6=B2=A1=E6=9C=89=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/ask/AskAncillaryHistoryResVO.java | 3 +++ .../mapper/DiagnosisAncillaryRecordMapper.xml | 1 + .../supervision/service/impl/AskServiceImpl.java | 14 ++++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskAncillaryHistoryResVO.java b/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskAncillaryHistoryResVO.java index c84a8d42..4fc4a8b9 100644 --- a/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskAncillaryHistoryResVO.java +++ b/virtual-patient-model/src/main/java/com/supervision/vo/ask/AskAncillaryHistoryResVO.java @@ -29,6 +29,9 @@ public class AskAncillaryHistoryResVO { @ApiModelProperty("辅助检查项结果") private String result; + @ApiModelProperty("位置名称") + private String locationName; + @ApiModelProperty("关联的初步诊断ID") private String primaryId; diff --git a/virtual-patient-model/src/main/resources/mapper/DiagnosisAncillaryRecordMapper.xml b/virtual-patient-model/src/main/resources/mapper/DiagnosisAncillaryRecordMapper.xml index fd671f04..bddca72f 100644 --- a/virtual-patient-model/src/main/resources/mapper/DiagnosisAncillaryRecordMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/DiagnosisAncillaryRecordMapper.xml @@ -47,6 +47,7 @@ t1.result as result, t1.assessment_result as assessmentResult, t1.id as id, + t2.location_name as locationName, t3.diagnosis_assessment_flag as diagnosisAssessmentFlag, t1.create_time as createTime from vp_diagnosis_ancillary_record t1 diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index 4e1d8e59..4639a2bf 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -203,7 +203,7 @@ public class AskServiceImpl implements AskService { String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId()); // 如果rasa没有识别出来,则返回默认值 if (StrUtil.isBlank(rasaResult)) { - downloadTalkVideo(defaultNoMatchId,response); + downloadTalkVideo(defaultNoMatchId, response); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } TalkResultResVO talkResultResVO = new TalkResultResVO(); @@ -225,7 +225,7 @@ public class AskServiceImpl implements AskService { AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); if (ObjectUtil.isEmpty(library)) { log.info("{}:未从问题库中找到,回答未识别语句", rasaResult); - downloadTalkVideo(defaultNoMatchId,response); + downloadTalkVideo(defaultNoMatchId, response); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } else { AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) @@ -236,7 +236,7 @@ public class AskServiceImpl implements AskService { // 首先看看default里面是不是存在,如果存在,就从default里面去找 if (StrUtil.isNotEmpty(library.getDefaultAnswer())) { String resText = library.getDefaultAnswer(); - downloadTalkVideo(defaultNoMatchId,response); + downloadTalkVideo(library.getDefaultAnswerResourceId(), response); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText()); @@ -257,13 +257,14 @@ public class AskServiceImpl implements AskService { saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); } else { log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult, askPatientAnswer.getId()); - downloadTalkVideo(defaultNoMatchId,response); + downloadTalkVideo(defaultNoMatchId, response); + saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); } } else { String resText = askPatientAnswer.getAnswer(); log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText); - downloadTalkVideo(askPatientAnswer.getAnswerResourceId(),response); + downloadTalkVideo(askPatientAnswer.getAnswerResourceId(), response); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText); } @@ -273,9 +274,6 @@ public class AskServiceImpl implements AskService { } talkResultResVO.setType(1); return talkResultResVO; - -// -// return null; } private void downloadTalkVideo(String fileId, HttpServletResponse response) { From 4ff3c6bf314ecb2c9471b636b4618af29253c345 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 15:45:56 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/AskTemplateQuestionLibraryMapper.xml | 3 ++- .../com/supervision/controller/AskController.java | 3 ++- .../com/supervision/pojo/vo/TalkVideoReqVO.java | 15 +++++++++++++++ .../java/com/supervision/service/AskService.java | 3 ++- .../supervision/service/impl/AskServiceImpl.java | 13 +++++-------- .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application-local.yml | 2 +- 7 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java diff --git a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml index 737a70a1..921b6c16 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml @@ -12,6 +12,7 @@ + @@ -21,7 +22,7 @@ id ,dict_id,code,description, - question,default_answer,create_user_id, + question,default_answer,default_answer_resources_id,create_user_id, create_time,update_user_id,update_time diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java index c7a226ea..fcc2d7e7 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java @@ -2,6 +2,7 @@ package com.supervision.controller; import com.supervision.pojo.vo.TalkReqVO; import com.supervision.pojo.vo.TalkResultResVO; +import com.supervision.pojo.vo.TalkVideoReqVO; import com.supervision.service.AskService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -36,7 +37,7 @@ public class AskController { @ApiOperation("使用本地视频的形式来做") @PostMapping("/talkByVideo") - public TalkResultResVO talkByVideo(@RequestBody TalkReqVO talkReqVO, HttpServletResponse response) throws IOException { + public TalkResultResVO talkByVideo(@RequestBody TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException { return askService.talkByVideo(talkReqVO,response); } diff --git a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java new file mode 100644 index 00000000..1389f56c --- /dev/null +++ b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java @@ -0,0 +1,15 @@ +package com.supervision.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class TalkVideoReqVO { + + @ApiModelProperty("对话内容") + private String text; + + @ApiModelProperty("流程ID") + private String processId; + +} diff --git a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java index 290e5585..176584fe 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java @@ -2,6 +2,7 @@ package com.supervision.service; import com.supervision.pojo.vo.TalkReqVO; import com.supervision.pojo.vo.TalkResultResVO; +import com.supervision.pojo.vo.TalkVideoReqVO; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; @@ -16,7 +17,7 @@ public interface AskService { TalkResultResVO talk(TalkReqVO talkReqVO) throws IOException; - TalkResultResVO talkByVideo(TalkReqVO talkReqVO, HttpServletResponse response) throws IOException; + TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException; } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index 4639a2bf..ad09b833 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -1,19 +1,17 @@ package com.supervision.service.impl; -import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.digest.MD5; import com.supervision.exception.BusinessException; -import com.supervision.model.*; import com.supervision.model.Process; +import com.supervision.model.*; import com.supervision.pojo.vo.TalkReqVO; import com.supervision.pojo.vo.TalkResultResVO; +import com.supervision.pojo.vo.TalkVideoReqVO; import com.supervision.service.*; import com.supervision.util.*; -import io.minio.MinioClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -24,7 +22,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.util.List; import java.util.Optional; @@ -196,11 +193,12 @@ public class AskServiceImpl implements AskService { } @Override - public TalkResultResVO talkByVideo(TalkReqVO talkReqVO, HttpServletResponse response) throws IOException { + public TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException { // 根据processId找到对应的病人 Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程")); // 调用rasa获取文字内容 String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId()); + log.info("rasa的回复是:{}",rasaResult); // 如果rasa没有识别出来,则返回默认值 if (StrUtil.isBlank(rasaResult)) { downloadTalkVideo(defaultNoMatchId, response); @@ -221,7 +219,6 @@ public class AskServiceImpl implements AskService { return talkResultResVO; } } else { - String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); if (ObjectUtil.isEmpty(library)) { log.info("{}:未从问题库中找到,回答未识别语句", rasaResult); @@ -242,7 +239,7 @@ public class AskServiceImpl implements AskService { log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText()); } else { log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult); - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); + downloadTalkVideo(library.getDefaultAnswerResourceId(), response); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); } } else { diff --git a/virtual-patient-web/src/main/resources/application-dev.yml b/virtual-patient-web/src/main/resources/application-dev.yml index 08c6b22f..5ba49b31 100644 --- a/virtual-patient-web/src/main/resources/application-dev.yml +++ b/virtual-patient-web/src/main/resources/application-dev.yml @@ -84,4 +84,4 @@ ws: nginx-ip: 192.168.10.138 nginx-port: 443 # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID -defaultNoMatchId: 1 \ No newline at end of file +defaultNoMatchId: 1739173836351885313 \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/application-local.yml b/virtual-patient-web/src/main/resources/application-local.yml index d4c0220e..46883679 100644 --- a/virtual-patient-web/src/main/resources/application-local.yml +++ b/virtual-patient-web/src/main/resources/application-local.yml @@ -85,4 +85,4 @@ ws: nginx-ip: 192.168.10.138 nginx-port: 443 # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID -defaultNoMatchId: 1 \ No newline at end of file +defaultNoMatchId: 1739173836351885313 \ No newline at end of file From b86e582e6e20115ebd6d5b83bbd8fbf3a1194147 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 16:10:40 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/supervision/service/impl/AskServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index ad09b833..d631f5bf 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -231,7 +231,7 @@ public class AskServiceImpl implements AskService { if (ObjectUtil.isEmpty(askPatientAnswer)) { log.info("{}:病历配置,未从AskPatientAnswer中找到回答结果,尝试回答默认答案", rasaResult); // 首先看看default里面是不是存在,如果存在,就从default里面去找 - if (StrUtil.isNotEmpty(library.getDefaultAnswer())) { + if (StrUtil.isNotEmpty(library.getDefaultAnswer()) && StrUtil.isNotBlank(library.getDefaultAnswerResourceId())) { String resText = library.getDefaultAnswer(); downloadTalkVideo(library.getDefaultAnswerResourceId(), response); // 保存记录 From 167181c66c70482455151160c3698c46c3074b91 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 17:11:57 +0800 Subject: [PATCH 09/14] bugfix --- .../impl/MedicalRecordServiceImpl.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/MedicalRecordServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/MedicalRecordServiceImpl.java index c36bf1be..f3462217 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/MedicalRecordServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/MedicalRecordServiceImpl.java @@ -48,9 +48,12 @@ public class MedicalRecordServiceImpl implements MedicalRecordService { @Override public ProcessMedicalResVo findByProcessId(String processId) { - Assert.notEmpty(processId,"流程id不允许为空"); + Assert.notEmpty(processId, "流程id不允许为空"); // 每次查询电子病历,就等于进到页面了,这时进行更新最后问诊时间 - processService.lambdaUpdate().set(Process::getUpdateTime, LocalDateTime.now()).eq(Process::getId, processId).update(); + processService.lambdaUpdate().set(Process::getUpdateTime, LocalDateTime.now()) + // 已评估的,不更新 + .ne(Process::getStatus, 2) + .eq(Process::getId, processId).update(); return processMedicalService.findByProcessId(processId); } @@ -58,9 +61,9 @@ public class MedicalRecordServiceImpl implements MedicalRecordService { public boolean saveOrUpdateMedicalRecord(ProcessMedical processMedical) { log.info(JSONUtil.toJsonStr(processMedical)); - Assert.notEmpty(processMedical.getProcessId(),"流程id不为空"); + Assert.notEmpty(processMedical.getProcessId(), "流程id不为空"); List list = processMedicalService.lambdaQuery().eq(ProcessMedical::getProcessId, processMedical.getProcessId()).list(); - if (CollUtil.isEmpty(list)){ + if (CollUtil.isEmpty(list)) { // 新增 return saveMedicalRecord(processMedical); } @@ -73,11 +76,11 @@ public class MedicalRecordServiceImpl implements MedicalRecordService { @Override public ProcessMedicalViewDetailResVo queryViewDetail(String processId) { - Assert.notEmpty(processId,"流程id不能为空"); + Assert.notEmpty(processId, "流程id不能为空"); // 1.获取电子病例基本信息 ProcessMedicalResVo processMedicalResVo = this.findByProcessId(processId); - if (Objects.isNull(processMedicalResVo)){ + if (Objects.isNull(processMedicalResVo)) { return null; } ProcessMedicalViewDetailResVo resultVo = BeanUtil.toBean(processMedicalResVo, ProcessMedicalViewDetailResVo.class); @@ -99,28 +102,28 @@ public class MedicalRecordServiceImpl implements MedicalRecordService { // 4. 获取用户姓名 User user = userService.getById(processMedicalResVo.getUserId()); - if (Objects.nonNull(user)){ + if (Objects.nonNull(user)) { resultVo.setUserName(user.getName()); } return resultVo; } - private void saveAssert(ProcessMedical processMedical){ - Assert.notEmpty(processMedical.getProcessId(),"流程id不为空"); + private void saveAssert(ProcessMedical processMedical) { + Assert.notEmpty(processMedical.getProcessId(), "流程id不为空"); Process process = processService.getById(processMedical.getProcessId()); - Assert.notNull(process,"流程数据不存在"); + Assert.notNull(process, "流程数据不存在"); processMedical.setMedicalRecId(process.getMedicalRecId()); processMedical.setPatientId(process.getPatientId()); - if (StrUtil.isEmpty(processMedical.getDiseaseId())){ + if (StrUtil.isEmpty(processMedical.getDiseaseId())) { processMedical.setDiseaseId(process.getDiseaseId()); } Integer count = processMedicalService.lambdaQuery().eq(ProcessMedical::getProcessId, processMedical.getProcessId()).count(); - Assert.isFalse(count > 0,"当前实例已经存在电子病例信息"); + Assert.isFalse(count > 0, "当前实例已经存在电子病例信息"); } } From 3a2217e3d985121dce3b02b6d3fa76db5ea6d070 Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 26 Dec 2023 09:08:50 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9A=82=E5=AD=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AskPrimaryController.java | 5 ++- .../pojo/vo/PrimaryConfirmNodeReqVO.java | 21 ++++++++++ .../pojo/vo/PrimaryConfirmReqVO.java | 13 ++---- .../service/AskPrimaryService.java | 2 +- .../service/impl/AskPrimaryServiceImpl.java | 42 ++++++++++++------- 5 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmNodeReqVO.java diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskPrimaryController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskPrimaryController.java index 43c8b856..d188da87 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskPrimaryController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskPrimaryController.java @@ -83,7 +83,8 @@ public class AskPrimaryController { @ApiOperation("确认诊断页面,保存初步诊断以及鉴别依据") @PostMapping("confirmPrimaryByAskEnd") - public void confirmPrimaryByAskEnd(@RequestBody @Valid List reqVOList) { - askPrimaryService.confirmPrimaryByAskEnd(reqVOList); + public void confirmPrimaryByAskEnd(@RequestBody @Valid PrimaryConfirmReqVO reqVO) { + askPrimaryService.confirmPrimaryByAskEnd(reqVO); } + } diff --git a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmNodeReqVO.java b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmNodeReqVO.java new file mode 100644 index 00000000..19854c6c --- /dev/null +++ b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmNodeReqVO.java @@ -0,0 +1,21 @@ +package com.supervision.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +@Data +public class PrimaryConfirmNodeReqVO { + + @ApiModelProperty("初步诊断ID") + @NotBlank(message = "初步诊断ID不能为空") + private String primaryId; + + @ApiModelProperty("是否排除(0排除1确诊)") + private Integer excludeFlag; + + @ApiModelProperty("诊断依据列表") + private List diagnosticBasisList; +} diff --git a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmReqVO.java b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmReqVO.java index aa32e468..07c4fb50 100644 --- a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmReqVO.java +++ b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/PrimaryConfirmReqVO.java @@ -9,17 +9,12 @@ import java.util.List; @Data public class PrimaryConfirmReqVO { - @ApiModelProperty("初步诊断ID") - @NotBlank(message = "初步诊断ID不能为空") - private String primaryId; - @NotBlank(message = "流程ID不能为空") private String processId; + @ApiModelProperty("是否暂存,1是,0否(否就是直接诊毕)") + private Integer tempSaveFlag; - @ApiModelProperty("是否排除(0排除1确诊)") - private Integer excludeFlag; - - @ApiModelProperty("诊断依据列表") - private List diagnosticBasisList; + @ApiModelProperty("确认结果") + private List primaryConfirmList; } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/AskPrimaryService.java b/virtual-patient-web/src/main/java/com/supervision/service/AskPrimaryService.java index 0eb78674..bf689abe 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/AskPrimaryService.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/AskPrimaryService.java @@ -27,7 +27,7 @@ public interface AskPrimaryService { RecordForPrimaryChooseVO queryRecordForPrimaryChoose(String processId); - void confirmPrimaryByAskEnd(List reqVOList); + void confirmPrimaryByAskEnd(PrimaryConfirmReqVO reqVO); void deletePrimary(String id); diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java index 3f5e46fe..c525d474 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskPrimaryServiceImpl.java @@ -197,29 +197,41 @@ public class AskPrimaryServiceImpl implements AskPrimaryService { @Override @Transactional(rollbackFor = Exception.class) - public void confirmPrimaryByAskEnd(List reqVOList) { - Optional any = reqVOList.stream().findAny(); + public void confirmPrimaryByAskEnd(PrimaryConfirmReqVO reqVO) { + List reqVOList = reqVO.getPrimaryConfirmList(); + Optional any = reqVOList.stream().findAny(); if (!any.isPresent()) { throw new BusinessException("初步诊断不能为空"); } - String processId = any.get().getProcessId(); - // 校验,如果没有填写病历,那么就不允许诊毕 - Integer count = processMedicalService.lambdaQuery().eq(ProcessMedical::getProcessId, processId).count(); - if (count < 1) { - throw new BusinessException("电子病历未填写,请填写电子病例后诊毕"); + // 如果 != 1 ,不是暂存,那么就校验电子病历是否填写 + if (ObjectUtil.isEmpty(reqVO.getTempSaveFlag()) || 1 != reqVO.getTempSaveFlag()){ + // 校验,如果没有填写病历,那么就不允许诊毕 + Integer count = processMedicalService.lambdaQuery().eq(ProcessMedical::getProcessId, reqVO.getProcessId()).count(); + if (count < 1) { + throw new BusinessException("电子病历未填写,请填写电子病例后诊毕"); + } } - for (PrimaryConfirmReqVO reqVO : reqVOList) { - if (ObjectUtil.isEmpty(reqVO.getExcludeFlag()) && 0 != reqVO.getExcludeFlag() && 1 != reqVO.getExcludeFlag()) { - throw new BusinessException("是否排除不能为空或诊断不正确"); + + + for (PrimaryConfirmNodeReqVO node : reqVOList) { + // 如果 != 1 ,不是暂存,那么就校验初步诊断是否填写 + if (ObjectUtil.isEmpty(reqVO.getTempSaveFlag()) || 1 != reqVO.getTempSaveFlag()){ + if (ObjectUtil.isEmpty(node.getExcludeFlag()) && 0 != node.getExcludeFlag() && 1 != node.getExcludeFlag()) { + throw new BusinessException("是否排除不能为空或诊断不正确"); + } } // 修改初步诊断是否被排除 - diagnosisPrimaryService.lambdaUpdate().set(DiagnosisPrimary::getExcludeFlag, reqVO.getExcludeFlag()) - .eq(DiagnosisPrimary::getId, reqVO.getPrimaryId()).update(); + diagnosisPrimaryService.lambdaUpdate().set(DiagnosisPrimary::getExcludeFlag, node.getExcludeFlag()) + .eq(DiagnosisPrimary::getId, node.getPrimaryId()).update(); // 保存证实诊断依据 - saveDiagnosticBasis(reqVO.getDiagnosticBasisList()); + saveDiagnosticBasis(node.getDiagnosticBasisList()); + } + // 如果 != 1 ,说明是诊毕,这时就诊毕 + if (ObjectUtil.isEmpty(reqVO.getTempSaveFlag()) || 1 != reqVO.getTempSaveFlag()) { + // 然后将process的状态改为诊毕 + processService.lambdaUpdate().set(Process::getStatus, 1).eq(Process::getId, reqVO.getProcessId()).update(); } - // 然后将process的状态改为诊毕 - processService.lambdaUpdate().set(Process::getStatus, 1).eq(Process::getId, processId).update(); + } private void saveDiagnosticBasis(List diagnosticBasisList) { From 37e5a93833a7dc8771905b93bce4ee804fb7bd3d Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 26 Dec 2023 11:11:09 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=96=B9=E6=A1=88=E7=9A=84=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/supervision/config/WebConfig.java | 1 + .../supervision/controller/AskController.java | 11 +++++-- .../supervision/pojo/vo/TalkResultResVO.java | 4 +++ .../com/supervision/service/AskService.java | 5 +++- .../service/impl/AskServiceImpl.java | 29 +++++++++++-------- .../src/main/resources/application-dev.yml | 4 ++- .../src/main/resources/application-local.yml | 4 ++- 7 files changed, 41 insertions(+), 17 deletions(-) diff --git a/virtual-patient-common/src/main/java/com/supervision/config/WebConfig.java b/virtual-patient-common/src/main/java/com/supervision/config/WebConfig.java index fa9bd682..47f2ceb5 100644 --- a/virtual-patient-common/src/main/java/com/supervision/config/WebConfig.java +++ b/virtual-patient-common/src/main/java/com/supervision/config/WebConfig.java @@ -42,6 +42,7 @@ public class WebConfig implements WebMvcConfigurer { paths.add("/favicon.ico"); paths.add("/user/login"); paths.add("/webSocket/**"); + paths.add("/ask/downloadTalkVideo"); // 开发环境,放开不校验token.每次修改这里需要重启(热部署不行) // paths.add("/**"); return paths; diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java index fcc2d7e7..390ca860 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java @@ -37,10 +37,17 @@ public class AskController { @ApiOperation("使用本地视频的形式来做") @PostMapping("/talkByVideo") - public TalkResultResVO talkByVideo(@RequestBody TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException { - return askService.talkByVideo(talkReqVO,response); + public TalkResultResVO talkByVideo(@RequestBody TalkVideoReqVO talkReqVO) throws IOException { + return askService.talkByVideo(talkReqVO); } + @ApiOperation("获取本地视频的文件流") + @GetMapping("/downloadTalkVideo") + public void downloadTalkVideo(String fileResourceId, HttpServletResponse response) { + askService.downloadTalkVideo(fileResourceId, response); + response.setContentType("video/mp4"); + } + } diff --git a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkResultResVO.java b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkResultResVO.java index 8ffb27d3..19ba7ca7 100644 --- a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkResultResVO.java +++ b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkResultResVO.java @@ -29,6 +29,10 @@ public class TalkResultResVO { @ApiModelProperty("type='2' 是否需要检查部位 0:否 1:是") private Integer requireLocation; + @ApiModelProperty("视频预览URL,本地视频的形式需要") + private String videoUrl; + + } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java index 176584fe..f78516b9 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java @@ -17,7 +17,10 @@ public interface AskService { TalkResultResVO talk(TalkReqVO talkReqVO) throws IOException; - TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException; + TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO) throws IOException; + + + void downloadTalkVideo(String fileResourceId, HttpServletResponse response); } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index d631f5bf..309021e4 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -45,6 +45,9 @@ public class AskServiceImpl implements AskService { @Value("${defaultNoMatchId}") private String defaultNoMatchId; + @Value("${video-url}") + private String videoUrl; + @Override public String receiveVoiceFile(MultipartFile file) { @@ -193,18 +196,19 @@ public class AskServiceImpl implements AskService { } @Override - public TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException { + public TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO) throws IOException { // 根据processId找到对应的病人 Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程")); // 调用rasa获取文字内容 String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId()); - log.info("rasa的回复是:{}",rasaResult); + log.info("rasa的回复是:{}", rasaResult); + TalkResultResVO talkResultResVO = new TalkResultResVO(); // 如果rasa没有识别出来,则返回默认值 if (StrUtil.isBlank(rasaResult)) { - downloadTalkVideo(defaultNoMatchId, response); + talkResultResVO.setVideoUrl(videoUrl + defaultNoMatchId); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } - TalkResultResVO talkResultResVO = new TalkResultResVO(); + // 这里校验,rasa回复的结果是不是action // 这里设置的模板,对于action的动作全部是用ancillary_ | tool_进行标记,详情看生成rasa的yml的代码:RasaServiceImpl.generateDomain // ancillary_ | tool_ @@ -222,7 +226,7 @@ public class AskServiceImpl implements AskService { AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); if (ObjectUtil.isEmpty(library)) { log.info("{}:未从问题库中找到,回答未识别语句", rasaResult); - downloadTalkVideo(defaultNoMatchId, response); + talkResultResVO.setVideoUrl(videoUrl + defaultNoMatchId); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } else { AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) @@ -233,13 +237,13 @@ public class AskServiceImpl implements AskService { // 首先看看default里面是不是存在,如果存在,就从default里面去找 if (StrUtil.isNotEmpty(library.getDefaultAnswer()) && StrUtil.isNotBlank(library.getDefaultAnswerResourceId())) { String resText = library.getDefaultAnswer(); - downloadTalkVideo(library.getDefaultAnswerResourceId(), response); + talkResultResVO.setVideoUrl(videoUrl + library.getDefaultAnswerResourceId()); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText()); } else { log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult); - downloadTalkVideo(library.getDefaultAnswerResourceId(), response); + talkResultResVO.setVideoUrl(videoUrl + library.getDefaultAnswerResourceId()); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); } } else { @@ -249,19 +253,19 @@ public class AskServiceImpl implements AskService { String resText = library.getDefaultAnswer(); log.info("{}:病历配置的回答:{}:为空不为空不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, askPatientAnswer.getId(), resText); // 这里返回视频 - downloadTalkVideo(library.getDefaultAnswerResourceId(), response); + talkResultResVO.setVideoUrl(videoUrl + library.getDefaultAnswerResourceId()); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); } else { log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult, askPatientAnswer.getId()); - downloadTalkVideo(defaultNoMatchId, response); + talkResultResVO.setVideoUrl(videoUrl + defaultNoMatchId); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); } } else { String resText = askPatientAnswer.getAnswer(); log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText); - downloadTalkVideo(askPatientAnswer.getAnswerResourceId(), response); + talkResultResVO.setVideoUrl(videoUrl + askPatientAnswer.getAnswerResourceId()); // 保存记录 saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText); } @@ -273,8 +277,9 @@ public class AskServiceImpl implements AskService { return talkResultResVO; } - private void downloadTalkVideo(String fileId, HttpServletResponse response) { - FileResource fileResource = fileResourceService.getById(fileId); + @Override + public void downloadTalkVideo(String fileResourceId, HttpServletResponse response) { + FileResource fileResource = fileResourceService.getById(fileResourceId); if (ObjectUtil.isEmpty(fileResource)) { throw new BusinessException("未找到回复视频"); } diff --git a/virtual-patient-web/src/main/resources/application-dev.yml b/virtual-patient-web/src/main/resources/application-dev.yml index 5ba49b31..10d84831 100644 --- a/virtual-patient-web/src/main/resources/application-dev.yml +++ b/virtual-patient-web/src/main/resources/application-dev.yml @@ -84,4 +84,6 @@ ws: nginx-ip: 192.168.10.138 nginx-port: 443 # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID -defaultNoMatchId: 1739173836351885313 \ No newline at end of file +defaultNoMatchId: 1739173836351885313 +# 视频预览 +video-url: http://192.168.10.138:8899/virtual-patient/ \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/application-local.yml b/virtual-patient-web/src/main/resources/application-local.yml index 46883679..aed64f59 100644 --- a/virtual-patient-web/src/main/resources/application-local.yml +++ b/virtual-patient-web/src/main/resources/application-local.yml @@ -85,4 +85,6 @@ ws: nginx-ip: 192.168.10.138 nginx-port: 443 # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID -defaultNoMatchId: 1739173836351885313 \ No newline at end of file +defaultNoMatchId: 1739173836351885313 +# 视频预览 +video-url: http://192.168.10.138:8899/virtual-patient/ask/downloadTalkVideo?fileResourceId= \ No newline at end of file From 696bbaaf05b9d5ae3afa3beca9acf144aadc2721 Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 26 Dec 2023 13:31:09 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=96=B9=E6=A1=88=E7=9A=84=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- virtual-patient-web/src/main/resources/application-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtual-patient-web/src/main/resources/application-dev.yml b/virtual-patient-web/src/main/resources/application-dev.yml index 10d84831..7522c86e 100644 --- a/virtual-patient-web/src/main/resources/application-dev.yml +++ b/virtual-patient-web/src/main/resources/application-dev.yml @@ -86,4 +86,4 @@ ws: # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID defaultNoMatchId: 1739173836351885313 # 视频预览 -video-url: http://192.168.10.138:8899/virtual-patient/ \ No newline at end of file +video-url: http://192.168.10.138:8899/virtual-patient/ask/downloadTalkVideo?fileResourceId= \ No newline at end of file From 8663175bb41599c6a3d639214cd9a67b5a885b7c Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 26 Dec 2023 13:47:59 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/supervision/service/impl/AskServiceImpl.java | 8 ++++---- .../src/main/java/com/supervision/util/RasaUtil.java | 5 +++-- .../src/main/resources/application-dev.yml | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index 309021e4..8d220b95 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -73,7 +73,7 @@ public class AskServiceImpl implements AskService { // 根据processId找到对应的病人 Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程")); // 调用rasa获取文字内容 - String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId()); + String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId()); // 如果rasa没有识别出来,则返回默认值 if (StrUtil.isBlank(rasaResult)) { // 这里调用京东数字人接口首先根据token获取房间号 @@ -103,7 +103,7 @@ public class AskServiceImpl implements AskService { HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } else { - AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) + AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, process.getMedicalRecId()) .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); // 如果没有找到回答,去默认回答里面看看有没有 if (ObjectUtil.isEmpty(askPatientAnswer)) { @@ -200,7 +200,7 @@ public class AskServiceImpl implements AskService { // 根据processId找到对应的病人 Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程")); // 调用rasa获取文字内容 - String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId()); + String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId()); log.info("rasa的回复是:{}", rasaResult); TalkResultResVO talkResultResVO = new TalkResultResVO(); // 如果rasa没有识别出来,则返回默认值 @@ -229,7 +229,7 @@ public class AskServiceImpl implements AskService { talkResultResVO.setVideoUrl(videoUrl + defaultNoMatchId); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } else { - AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) + AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, process.getMedicalRecId()) .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); // 如果没有找到回答,去默认回答里面看看有没有 if (ObjectUtil.isEmpty(askPatientAnswer)) { diff --git a/virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java b/virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java index 420be126..644545b7 100644 --- a/virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java +++ b/virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java @@ -24,11 +24,12 @@ public class RasaUtil { private static final Environment environment = SpringBeanUtil.getBean(Environment.class); private static final String RASA_TALK_URL = environment.getProperty("rasa.base-url") + environment.getProperty("rasa.talk"); - public static String talkRasa(String question, String sessionId, String patientId) { + public static String talkRasa(String question, String sessionId) { RasaTalkVo rasaTalkVo = new RasaTalkVo(); rasaTalkVo.setQuestion(question); rasaTalkVo.setSessionId(sessionId); - rasaTalkVo.setModelId(patientId); + // 默认为1 + rasaTalkVo.setModelId("1"); String post = HttpUtil.post(RASA_TALK_URL, JSONUtil.toJsonStr(rasaTalkVo)); log.info("调用rasa对话返回结果:{}", post); try { diff --git a/virtual-patient-web/src/main/resources/application-dev.yml b/virtual-patient-web/src/main/resources/application-dev.yml index 7522c86e..379bcc76 100644 --- a/virtual-patient-web/src/main/resources/application-dev.yml +++ b/virtual-patient-web/src/main/resources/application-dev.yml @@ -85,5 +85,5 @@ ws: nginx-port: 443 # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID defaultNoMatchId: 1739173836351885313 -# 视频预览 -video-url: http://192.168.10.138:8899/virtual-patient/ask/downloadTalkVideo?fileResourceId= \ No newline at end of file +# 视频预览,NGINX的地址,https的地址 +video-url: https://192.168.10.138:443/virtual-patient/ask/downloadTalkVideo?fileResourceId= \ No newline at end of file From bc683dbfae27be0033d56b1adf8378813f29255a Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 26 Dec 2023 13:51:41 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E4=BC=98=E5=8C=96,=E5=8E=BB=E9=99=A4answ?= =?UTF-8?q?er=E7=9A=84patient=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/service/impl/MedicalRecManageServiceImpl.java | 2 -- .../main/java/com/supervision/model/AskPatientAnswer.java | 5 ----- .../src/main/resources/mapper/AskPatientAnswerMapper.xml | 3 +-- .../service/impl/AskDiagnosisResultServiceImpl.java | 7 +++---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java index ee835dc2..35ae54b5 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java @@ -95,7 +95,6 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService { askPatientAnswer.setLibraryQuestionId(medicalRecQaVO.getLibraryQuestionId()); askPatientAnswer.setAnswer(medicalRecQaVO.getMedicalRecAnswer()); askPatientAnswer.setMedicalId(medicalRec.getId()); - askPatientAnswer.setPatientId(patient.getId()); askPatientAnswer.insert(); } } @@ -184,7 +183,6 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService { askPatientAnswer.setLibraryQuestionId(medicalRecQaVO.getLibraryQuestionId()); askPatientAnswer.setAnswer(medicalRecQaVO.getMedicalRecAnswer()); askPatientAnswer.setMedicalId(medicalRec.getId()); - askPatientAnswer.setPatientId(patient.getId()); askPatientAnswer.insert(); } } diff --git a/virtual-patient-model/src/main/java/com/supervision/model/AskPatientAnswer.java b/virtual-patient-model/src/main/java/com/supervision/model/AskPatientAnswer.java index bdc2ff02..82dce8ab 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/AskPatientAnswer.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/AskPatientAnswer.java @@ -26,11 +26,6 @@ public class AskPatientAnswer extends Model implements Seriali @TableId private String id; - /** - * 病人ID - */ - private String patientId; - @ApiModelProperty("病例id") private String medicalId; diff --git a/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml index e79f4bbc..ba972fbb 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml @@ -6,7 +6,6 @@ - @@ -18,7 +17,7 @@ - id,patient_id,medical_id,library_question_id, + id,medical_id,library_question_id, answer,answer_resources_id,create_user_id, create_time,update_user_id,update_time diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java index 63449689..ca61f8f1 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java @@ -56,13 +56,12 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService DiagnosisResultResVO diagnosisResultResVO = new DiagnosisResultResVO(); diagnosisResultResVO.setId(processId); Process process = processService.getById(processId); - Patient patient = patientService.getById(process.getPatientId()); MedicalRec medicalRec = medicalRecService.getById(process.getMedicalRecId()); List diseasesList = diseaseService.listDiseaseWithType(medicalRec.getDiseaseId()); // 1.生成预期诊断结果 diagnosisResultResVO.setExpertDiagnosisResult(creatExpertDiagnosisResult(medicalRec, diseasesList, processId)); // 2.生成初步诊断依据 - diagnosisResultResVO.setBasisPrimaryResultResVO(createBasisPrimaryResult(patient, medicalRec, process)); + diagnosisResultResVO.setBasisPrimaryResultResVO(createBasisPrimaryResult(medicalRec, process)); // 3.生成证实诊断依据 diagnosisResultResVO.setBasisConfirmResultResVO(createBasisConfirmResult(medicalRec, processId)); // 4.生成鉴别诊断依据 @@ -180,7 +179,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService return basisConfirmResultResVO; } - private BasisPrimaryResultResVO createBasisPrimaryResult(Patient patient, MedicalRec medicalRec, Process process) { + private BasisPrimaryResultResVO createBasisPrimaryResult( MedicalRec medicalRec, Process process) { BasisPrimaryResultResVO basisPrimaryResultResVO = new BasisPrimaryResultResVO(); // 初步诊断依据 vp_medical_rec的primarily_diagnosis_criteria basisPrimaryResultResVO.setPreliminaryDiagnosis(medicalRec.getPrimarilyDiagnosisCriteria()); @@ -190,7 +189,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService List qaRecordList = diagnosisQaRecordService.lambdaQuery().eq(DiagnosisQaRecord::getProcessId, process.getId()).list(); if (CollectionUtil.isNotEmpty(qaRecordList)) { List list = askPatientAnswerService.lambdaQuery() - .eq(AskPatientAnswer::getPatientId, patient.getId()).list(); + .eq(AskPatientAnswer::getMedicalId, medicalRec.getId()).list(); // 获取配置了答案的项目(配置了答案的,认为是正确,没有配置答案的,走默认回答的,不标记为以正确) Set requireCheckIdSet = list.stream().map(AskPatientAnswer::getId).collect(Collectors.toSet()); List qaList = qaRecordList.stream().map(e -> {