From 890ac07eda1a65074a7b2849beb405b35e5bb5ce Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 13:12:34 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AskDefaultQuestionAnswerMapper.java | 18 ---- .../AskDiseaseQuestionAnswerMapper.java | 18 ---- .../mapper/AskPatientAnswerMapper.java | 18 ++++ .../AskTemplateQuestionLibraryMapper.java | 18 ++++ .../mapper/AskTemplateQuestionMapper.java | 18 ---- .../supervision/mapper/MedicalRecMapper.java | 18 ++++ .../model/AskDiseaseQuestionAnswer.java | 96 ------------------- ...ateQuestion.java => AskPatientAnswer.java} | 32 +++---- ...r.java => AskTemplateQuestionLibrary.java} | 21 ++-- .../supervision/model/DiagnosisQaRecord.java | 3 - .../java/com/supervision/model/Disease.java | 7 +- .../supervision/model/DiseaseAncillary.java | 6 +- .../supervision/model/DiseasePhysical.java | 7 +- .../com/supervision/model/MedicalRec.java | 91 ++++++++++++++++++ .../java/com/supervision/model/Patient.java | 21 +--- .../java/com/supervision/model/Process.java | 5 +- .../AskDefaultQuestionAnswerService.java | 13 --- .../AskDiseaseQuestionAnswerService.java | 13 --- .../service/AskPatientAnswerService.java | 13 +++ .../AskTemplateQuestionLibraryService.java | 13 +++ .../service/AskTemplateQuestionService.java | 13 --- .../service/MedicalRecService.java | 13 +++ .../AskDefaultQuestionAnswerServiceImpl.java | 22 ----- .../AskDiseaseQuestionAnswerServiceImpl.java | 22 ----- .../impl/AskPatientAnswerServiceImpl.java | 22 +++++ ...AskTemplateQuestionLibraryServiceImpl.java | 22 +++++ .../impl/AskTemplateQuestionServiceImpl.java | 22 ----- .../service/impl/MedicalRecServiceImpl.java | 22 +++++ .../mapper/AskDiseaseQuestionAnswerMapper.xml | 27 ------ ...rMapper.xml => AskPatientAnswerMapper.xml} | 16 ++-- ...l => AskTemplateQuestionLibraryMapper.xml} | 11 ++- .../resources/mapper/MedicalRecMapper.xml | 28 ++++++ .../controller/TestController.java | 42 -------- .../service/impl/AskAncillaryServiceImpl.java | 4 +- .../impl/AskDiagnosisResultServiceImpl.java | 36 +++---- .../service/impl/AskPhysicalServiceImpl.java | 2 +- .../service/impl/AskServiceImpl.java | 72 +++++++------- .../service/impl/RasaServiceImpl.java | 69 +++---------- 38 files changed, 403 insertions(+), 511 deletions(-) delete mode 100644 virtual-patient-model/src/main/java/com/supervision/mapper/AskDefaultQuestionAnswerMapper.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/mapper/AskDiseaseQuestionAnswerMapper.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/mapper/AskPatientAnswerMapper.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionLibraryMapper.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionMapper.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/mapper/MedicalRecMapper.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/model/AskDiseaseQuestionAnswer.java rename virtual-patient-model/src/main/java/com/supervision/model/{AskTemplateQuestion.java => AskPatientAnswer.java} (60%) rename virtual-patient-model/src/main/java/com/supervision/model/{AskDefaultQuestionAnswer.java => AskTemplateQuestionLibrary.java} (70%) create mode 100644 virtual-patient-model/src/main/java/com/supervision/model/MedicalRec.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/service/AskDefaultQuestionAnswerService.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/service/AskDiseaseQuestionAnswerService.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/service/AskPatientAnswerService.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionLibraryService.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionService.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/service/MedicalRecService.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/service/impl/AskDefaultQuestionAnswerServiceImpl.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/service/impl/AskDiseaseQuestionAnswerServiceImpl.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/service/impl/AskPatientAnswerServiceImpl.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionLibraryServiceImpl.java delete mode 100644 virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionServiceImpl.java create mode 100644 virtual-patient-model/src/main/java/com/supervision/service/impl/MedicalRecServiceImpl.java delete mode 100644 virtual-patient-model/src/main/resources/mapper/AskDiseaseQuestionAnswerMapper.xml rename virtual-patient-model/src/main/resources/mapper/{AskDefaultQuestionAnswerMapper.xml => AskPatientAnswerMapper.xml} (60%) rename virtual-patient-model/src/main/resources/mapper/{AskTemplateQuestionMapper.xml => AskTemplateQuestionLibraryMapper.xml} (76%) create mode 100644 virtual-patient-model/src/main/resources/mapper/MedicalRecMapper.xml diff --git a/virtual-patient-model/src/main/java/com/supervision/mapper/AskDefaultQuestionAnswerMapper.java b/virtual-patient-model/src/main/java/com/supervision/mapper/AskDefaultQuestionAnswerMapper.java deleted file mode 100644 index 939e1a5f..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/mapper/AskDefaultQuestionAnswerMapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.supervision.mapper; - -import com.supervision.model.AskDefaultQuestionAnswer; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** -* @author flevance -* @description 针对表【vp_ask_default_question_answer(默认问询意图)】的数据库操作Mapper -* @createDate 2023-10-27 10:05:55 -* @Entity com.supervision.model.AskDefaultQuestionAnswer -*/ -public interface AskDefaultQuestionAnswerMapper extends BaseMapper { - -} - - - - diff --git a/virtual-patient-model/src/main/java/com/supervision/mapper/AskDiseaseQuestionAnswerMapper.java b/virtual-patient-model/src/main/java/com/supervision/mapper/AskDiseaseQuestionAnswerMapper.java deleted file mode 100644 index 9fbbdedc..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/mapper/AskDiseaseQuestionAnswerMapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.supervision.mapper; - -import com.supervision.model.AskDiseaseQuestionAnswer; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** -* @author flevance -* @description 针对表【vp_ask_disease_question_answer(诊断问询-疾病特有意图问题及回复)】的数据库操作Mapper -* @createDate 2023-10-27 10:05:55 -* @Entity com.supervision.model.AskDiseaseQuestionAnswer -*/ -public interface AskDiseaseQuestionAnswerMapper extends BaseMapper { - -} - - - - diff --git a/virtual-patient-model/src/main/java/com/supervision/mapper/AskPatientAnswerMapper.java b/virtual-patient-model/src/main/java/com/supervision/mapper/AskPatientAnswerMapper.java new file mode 100644 index 00000000..fe7a172b --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/mapper/AskPatientAnswerMapper.java @@ -0,0 +1,18 @@ +package com.supervision.mapper; + +import com.supervision.model.AskPatientAnswer; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author flevance +* @description 针对表【vp_ask_patient_answer(诊断问询-针对患者的回复)】的数据库操作Mapper +* @createDate 2023-11-03 11:13:26 +* @Entity com.supervision.model.AskPatientAnswer +*/ +public interface AskPatientAnswerMapper extends BaseMapper { + +} + + + + diff --git a/virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionLibraryMapper.java b/virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionLibraryMapper.java new file mode 100644 index 00000000..22be5eb9 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionLibraryMapper.java @@ -0,0 +1,18 @@ +package com.supervision.mapper; + +import com.supervision.model.AskTemplateQuestionLibrary; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author flevance +* @description 针对表【vp_ask_template_question_library(诊断问询意图问题库)】的数据库操作Mapper +* @createDate 2023-11-03 11:13:26 +* @Entity com.supervision.model.AskTemplateQuestionLibrary +*/ +public interface AskTemplateQuestionLibraryMapper extends BaseMapper { + +} + + + + diff --git a/virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionMapper.java b/virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionMapper.java deleted file mode 100644 index 7e449ccf..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/mapper/AskTemplateQuestionMapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.supervision.mapper; - -import com.supervision.model.AskTemplateQuestion; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** -* @author flevance -* @description 针对表【vp_ask_template_question(诊断问询意图)】的数据库操作Mapper -* @createDate 2023-10-27 10:05:55 -* @Entity com.supervision.model.AskTemplateQuestion -*/ -public interface AskTemplateQuestionMapper extends BaseMapper { - -} - - - - diff --git a/virtual-patient-model/src/main/java/com/supervision/mapper/MedicalRecMapper.java b/virtual-patient-model/src/main/java/com/supervision/mapper/MedicalRecMapper.java new file mode 100644 index 00000000..17ecf939 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/mapper/MedicalRecMapper.java @@ -0,0 +1,18 @@ +package com.supervision.mapper; + +import com.supervision.model.MedicalRec; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author flevance +* @description 针对表【vp_medical_rec(病历表)】的数据库操作Mapper +* @createDate 2023-11-03 11:25:43 +* @Entity com.supervision.model.MedicalRec +*/ +public interface MedicalRecMapper extends BaseMapper { + +} + + + + diff --git a/virtual-patient-model/src/main/java/com/supervision/model/AskDiseaseQuestionAnswer.java b/virtual-patient-model/src/main/java/com/supervision/model/AskDiseaseQuestionAnswer.java deleted file mode 100644 index e6da314b..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/model/AskDiseaseQuestionAnswer.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.supervision.model; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.List; - -import com.baomidou.mybatisplus.extension.activerecord.Model; -import com.supervision.handler.StringListTypeHandler; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * 诊断问询-疾病特有意图问题及回复 - * - * @TableName vp_ask_disease_question_answer - */ -@TableName(value = "vp_ask_disease_question_answer", autoResultMap = true) -@Data -@ApiModel -public class AskDiseaseQuestionAnswer extends Model implements Serializable { - /** - * 主键 - */ - @TableId - private String id; - - /** - * 病人ID - */ - @ApiModelProperty("病人ID") - private String patientId; - - /** - * 模板问题ID(如果not null,则从template_question表出code,desc,question) - */ - @ApiModelProperty("模板问题ID(如果not null,则从template_question表出code,desc,question)") - private String templateQuestionId; - - /** - * 编码 - */ - @ApiModelProperty("编码") - private String code; - - /** - * 中文注释 - */ - @ApiModelProperty("中文注释") - private String description; - - /** - * 问题列表 - */ - @ApiModelProperty("问题列表") - @TableField(typeHandler = StringListTypeHandler.class) - private List question; - - /** - * 回答列表 - */ - @ApiModelProperty("回答列表") - @TableField(typeHandler = StringListTypeHandler.class) - private List answer; - - @ApiModelProperty("是否必查-初步诊断依据 0否1是") - private Integer requireCheck; - - /** - * 创建人ID - */ - private String createUserId; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 更新人 - */ - private String updateUserId; - - /** - * 更新时间 - */ - private LocalDateTime updateTime; - - @TableField(exist = false) - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/virtual-patient-model/src/main/java/com/supervision/model/AskTemplateQuestion.java b/virtual-patient-model/src/main/java/com/supervision/model/AskPatientAnswer.java similarity index 60% rename from virtual-patient-model/src/main/java/com/supervision/model/AskTemplateQuestion.java rename to virtual-patient-model/src/main/java/com/supervision/model/AskPatientAnswer.java index 8bf54832..b1c14709 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/AskTemplateQuestion.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/AskPatientAnswer.java @@ -8,20 +8,16 @@ import java.io.Serializable; import java.time.LocalDateTime; import java.util.List; -import com.baomidou.mybatisplus.extension.activerecord.Model; import com.supervision.handler.StringListTypeHandler; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** - * 诊断问询意图 - * @TableName vp_ask_template_question + * 诊断问询-针对患者的回复 + * @TableName vp_ask_patient_answer */ -@TableName(value ="vp_ask_template_question",autoResultMap = true) +@TableName(value ="vp_ask_patient_answer",autoResultMap = true) @Data -@ApiModel -public class AskTemplateQuestion extends Model implements Serializable { +public class AskPatientAnswer implements Serializable { /** * 主键 */ @@ -29,23 +25,25 @@ public class AskTemplateQuestion extends Model implements S private String id; /** - * 编码 + * 病人ID */ - @ApiModelProperty("编码") - private String code; + private String patientId; /** - * 中文注释 + * 问题库问题ID */ - @ApiModelProperty("中文注释") - private String description; + private String libraryQuestionId; /** - * 问题列表 + * 回答 */ - @ApiModelProperty("问题列表") @TableField(typeHandler = StringListTypeHandler.class) - private List question; + private List answer; + + /** + * 是否必查-初步诊断依据 0否1是 + */ + private Integer requireCheck; /** * 创建人ID diff --git a/virtual-patient-model/src/main/java/com/supervision/model/AskDefaultQuestionAnswer.java b/virtual-patient-model/src/main/java/com/supervision/model/AskTemplateQuestionLibrary.java similarity index 70% rename from virtual-patient-model/src/main/java/com/supervision/model/AskDefaultQuestionAnswer.java rename to virtual-patient-model/src/main/java/com/supervision/model/AskTemplateQuestionLibrary.java index 1e1ad11d..0b7f7277 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/AskDefaultQuestionAnswer.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/AskTemplateQuestionLibrary.java @@ -4,25 +4,20 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - import java.io.Serializable; import java.time.LocalDateTime; import java.util.List; import com.supervision.handler.StringListTypeHandler; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** - * 默认问询意图 - * - * @TableName vp_ask_default_question_answer + * 诊断问询意图问题库 + * @TableName vp_ask_template_question_library */ -@TableName(value = "vp_ask_default_question_answer", autoResultMap = true) +@TableName(value ="vp_ask_template_question_library", autoResultMap = true) @Data -@ApiModel -public class AskDefaultQuestionAnswer implements Serializable { +public class AskTemplateQuestionLibrary implements Serializable { /** * 主键 */ @@ -32,28 +27,24 @@ public class AskDefaultQuestionAnswer implements Serializable { /** * 编码 */ - @ApiModelProperty("编码") private String code; /** * 中文注释 */ - @ApiModelProperty("中文注释") private String description; /** * 问题列表 */ - @ApiModelProperty("问题列表") @TableField(typeHandler = StringListTypeHandler.class) private List question; /** - * 回答列表 + * 默认问题的回答 */ - @ApiModelProperty("回答列表") @TableField(typeHandler = StringListTypeHandler.class) - private List answer; + private List defaultAnswer; /** * 创建人ID diff --git a/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java b/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java index 5b118db4..d4e996d4 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java @@ -32,9 +32,6 @@ public class DiagnosisQaRecord extends Model implements Seria @ApiModelProperty("诊断进程ID") private String processId; - @ApiModelProperty("问答类型:default,disease") - private String questionAnswerType; - /** * 问题答案表ID */ diff --git a/virtual-patient-model/src/main/java/com/supervision/model/Disease.java b/virtual-patient-model/src/main/java/com/supervision/model/Disease.java index 5d8c8848..a5e1796c 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/Disease.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/Disease.java @@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import java.time.LocalDateTime; +import java.util.List; +import com.supervision.handler.StringListTypeHandler; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -15,7 +17,7 @@ import lombok.Data; * 疾病名称 * @TableName vp_disease */ -@TableName(value ="vp_disease") +@TableName(value ="vp_disease", autoResultMap = true) @Data @ApiModel public class Disease implements Serializable { @@ -68,6 +70,9 @@ public class Disease implements Serializable { @ApiModelProperty("其他") private String other; + @TableField(typeHandler = StringListTypeHandler.class) + private List standardQuestionLibrary; + /** * 创建人ID diff --git a/virtual-patient-model/src/main/java/com/supervision/model/DiseaseAncillary.java b/virtual-patient-model/src/main/java/com/supervision/model/DiseaseAncillary.java index e0d4599a..06af2c04 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/DiseaseAncillary.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/DiseaseAncillary.java @@ -26,10 +26,10 @@ public class DiseaseAncillary implements Serializable { private String id; /** - * 病人ID + * 病历ID */ - @ApiModelProperty("病人ID") - private String patientId; + @ApiModelProperty("病历ID") + private String medicalRecId; /** * 工具ID diff --git a/virtual-patient-model/src/main/java/com/supervision/model/DiseasePhysical.java b/virtual-patient-model/src/main/java/com/supervision/model/DiseasePhysical.java index 9a187d12..67ff78f6 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/DiseasePhysical.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/DiseasePhysical.java @@ -26,11 +26,10 @@ public class DiseasePhysical implements Serializable { private String id; /** - * 病人ID + * 病历ID */ - @ApiModelProperty("病人ID") - private String patientId; - + @ApiModelProperty("病历ID") + private String medicalRecId; /** * 工具ID */ diff --git a/virtual-patient-model/src/main/java/com/supervision/model/MedicalRec.java b/virtual-patient-model/src/main/java/com/supervision/model/MedicalRec.java new file mode 100644 index 00000000..9684caa9 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/model/MedicalRec.java @@ -0,0 +1,91 @@ +package com.supervision.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.List; + +import com.supervision.handler.StringListTypeHandler; +import lombok.Data; + +/** + * 病历表 + * + * @TableName vp_medical_rec + */ +@TableName(value = "vp_medical_rec", autoResultMap = true) +@Data +public class MedicalRec implements Serializable { + /** + * 主键 + */ + @TableId + private String id; + + /** + * 病例编号 + */ + private String no; + + /** + * 病人ID + */ + private String patientId; + + /** + * 疾病列表 + */ + @TableField(typeHandler = StringListTypeHandler.class) + private List diseaseList; + + /** + * 患者主诉 + */ + private String patientSelfDesc; + + /** + * 症状 + */ + private String symptoms; + + /** + * 预期诊断结果 + */ + private String expectDiagnosisResult; + + /** + * 预期治疗计划 + */ + private String expectDiseaseTreatmentPlan; + + /** + * 初步诊断 + */ + private Object primaryDiagnosis; + + /** + * 过敏史 + */ + private String allergyHistory; + + /** + * 既往史 + */ + private String previousHistory; + + /** + * 家族史 + */ + private String familyHistory; + + /** + * 婚育史 + */ + private String marriageChildHistory; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/virtual-patient-model/src/main/java/com/supervision/model/Patient.java b/virtual-patient-model/src/main/java/com/supervision/model/Patient.java index af5d6958..5e4b4682 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/Patient.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/Patient.java @@ -18,7 +18,7 @@ import java.util.List; * * @TableName vp_patient */ -@TableName(value = "vp_patient", autoResultMap = true) +@TableName(value = "vp_patient") @Data @ApiModel public class Patient implements Serializable { @@ -64,25 +64,6 @@ public class Patient implements Serializable { @ApiModelProperty("体重") private BigDecimal weight; - /** - * 疾病列表 - */ - @ApiModelProperty("疾病列表") - @TableField(typeHandler = StringListTypeHandler.class) - private List diseaseList; - - /** - * 预期诊断结果 - */ - @ApiModelProperty("预期诊断结果") - private String expectedDiagnosisResult; - - /** - * 治疗计划 - */ - @ApiModelProperty("治疗计划") - private String diseaseTreatmentPlan; - /** * 创建人ID */ diff --git a/virtual-patient-model/src/main/java/com/supervision/model/Process.java b/virtual-patient-model/src/main/java/com/supervision/model/Process.java index fd6abade..cf172f33 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/Process.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/Process.java @@ -32,6 +32,9 @@ public class Process implements Serializable { @ApiModelProperty("病人ID") private String patientId; + @ApiModelProperty("病历ID") + private String medicalRecId; + /** * 用户ID */ @@ -41,7 +44,7 @@ public class Process implements Serializable { /** * 任务状态 0进行中 1已完成 */ - @ApiModelProperty("任务状态 0进行中 1已完成") + @ApiModelProperty("任务状态 -1未开始 0进行中 1已完成") private Integer status; /** diff --git a/virtual-patient-model/src/main/java/com/supervision/service/AskDefaultQuestionAnswerService.java b/virtual-patient-model/src/main/java/com/supervision/service/AskDefaultQuestionAnswerService.java deleted file mode 100644 index 2f3601f5..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/service/AskDefaultQuestionAnswerService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.supervision.service; - -import com.supervision.model.AskDefaultQuestionAnswer; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author flevance -* @description 针对表【vp_ask_default_question_answer(默认问询意图)】的数据库操作Service -* @createDate 2023-10-27 10:05:55 -*/ -public interface AskDefaultQuestionAnswerService extends IService { - -} diff --git a/virtual-patient-model/src/main/java/com/supervision/service/AskDiseaseQuestionAnswerService.java b/virtual-patient-model/src/main/java/com/supervision/service/AskDiseaseQuestionAnswerService.java deleted file mode 100644 index cad8c846..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/service/AskDiseaseQuestionAnswerService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.supervision.service; - -import com.supervision.model.AskDiseaseQuestionAnswer; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author flevance -* @description 针对表【vp_ask_disease_question_answer(诊断问询-疾病特有意图问题及回复)】的数据库操作Service -* @createDate 2023-10-27 10:05:55 -*/ -public interface AskDiseaseQuestionAnswerService extends IService { - -} diff --git a/virtual-patient-model/src/main/java/com/supervision/service/AskPatientAnswerService.java b/virtual-patient-model/src/main/java/com/supervision/service/AskPatientAnswerService.java new file mode 100644 index 00000000..1f2f978b --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/service/AskPatientAnswerService.java @@ -0,0 +1,13 @@ +package com.supervision.service; + +import com.supervision.model.AskPatientAnswer; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author flevance +* @description 针对表【vp_ask_patient_answer(诊断问询-针对患者的回复)】的数据库操作Service +* @createDate 2023-11-03 11:13:26 +*/ +public interface AskPatientAnswerService extends IService { + +} diff --git a/virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionLibraryService.java b/virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionLibraryService.java new file mode 100644 index 00000000..23cb0809 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionLibraryService.java @@ -0,0 +1,13 @@ +package com.supervision.service; + +import com.supervision.model.AskTemplateQuestionLibrary; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author flevance +* @description 针对表【vp_ask_template_question_library(诊断问询意图问题库)】的数据库操作Service +* @createDate 2023-11-03 11:13:26 +*/ +public interface AskTemplateQuestionLibraryService extends IService { + +} diff --git a/virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionService.java b/virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionService.java deleted file mode 100644 index a15af01c..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/service/AskTemplateQuestionService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.supervision.service; - -import com.supervision.model.AskTemplateQuestion; -import com.baomidou.mybatisplus.extension.service.IService; - -/** -* @author flevance -* @description 针对表【vp_ask_template_question(诊断问询意图)】的数据库操作Service -* @createDate 2023-10-27 10:05:55 -*/ -public interface AskTemplateQuestionService extends IService { - -} diff --git a/virtual-patient-model/src/main/java/com/supervision/service/MedicalRecService.java b/virtual-patient-model/src/main/java/com/supervision/service/MedicalRecService.java new file mode 100644 index 00000000..ceb949d8 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/service/MedicalRecService.java @@ -0,0 +1,13 @@ +package com.supervision.service; + +import com.supervision.model.MedicalRec; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author flevance +* @description 针对表【vp_medical_rec(病历表)】的数据库操作Service +* @createDate 2023-11-03 11:25:43 +*/ +public interface MedicalRecService extends IService { + +} diff --git a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskDefaultQuestionAnswerServiceImpl.java b/virtual-patient-model/src/main/java/com/supervision/service/impl/AskDefaultQuestionAnswerServiceImpl.java deleted file mode 100644 index 1b74f40c..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskDefaultQuestionAnswerServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.supervision.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.supervision.model.AskDefaultQuestionAnswer; -import com.supervision.service.AskDefaultQuestionAnswerService; -import com.supervision.mapper.AskDefaultQuestionAnswerMapper; -import org.springframework.stereotype.Service; - -/** -* @author flevance -* @description 针对表【vp_ask_default_question_answer(默认问询意图)】的数据库操作Service实现 -* @createDate 2023-10-27 10:05:55 -*/ -@Service -public class AskDefaultQuestionAnswerServiceImpl extends ServiceImpl - implements AskDefaultQuestionAnswerService{ - -} - - - - diff --git a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskDiseaseQuestionAnswerServiceImpl.java b/virtual-patient-model/src/main/java/com/supervision/service/impl/AskDiseaseQuestionAnswerServiceImpl.java deleted file mode 100644 index 55ddbfef..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskDiseaseQuestionAnswerServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.supervision.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.supervision.model.AskDiseaseQuestionAnswer; -import com.supervision.service.AskDiseaseQuestionAnswerService; -import com.supervision.mapper.AskDiseaseQuestionAnswerMapper; -import org.springframework.stereotype.Service; - -/** -* @author flevance -* @description 针对表【vp_ask_disease_question_answer(诊断问询-疾病特有意图问题及回复)】的数据库操作Service实现 -* @createDate 2023-10-27 10:05:55 -*/ -@Service -public class AskDiseaseQuestionAnswerServiceImpl extends ServiceImpl - implements AskDiseaseQuestionAnswerService{ - -} - - - - diff --git a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskPatientAnswerServiceImpl.java b/virtual-patient-model/src/main/java/com/supervision/service/impl/AskPatientAnswerServiceImpl.java new file mode 100644 index 00000000..83f66d36 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/service/impl/AskPatientAnswerServiceImpl.java @@ -0,0 +1,22 @@ +package com.supervision.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.supervision.model.AskPatientAnswer; +import com.supervision.service.AskPatientAnswerService; +import com.supervision.mapper.AskPatientAnswerMapper; +import org.springframework.stereotype.Service; + +/** +* @author flevance +* @description 针对表【vp_ask_patient_answer(诊断问询-针对患者的回复)】的数据库操作Service实现 +* @createDate 2023-11-03 11:13:26 +*/ +@Service +public class AskPatientAnswerServiceImpl extends ServiceImpl + implements AskPatientAnswerService{ + +} + + + + diff --git a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionLibraryServiceImpl.java b/virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionLibraryServiceImpl.java new file mode 100644 index 00000000..a4eecea5 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionLibraryServiceImpl.java @@ -0,0 +1,22 @@ +package com.supervision.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.supervision.model.AskTemplateQuestionLibrary; +import com.supervision.service.AskTemplateQuestionLibraryService; +import com.supervision.mapper.AskTemplateQuestionLibraryMapper; +import org.springframework.stereotype.Service; + +/** +* @author flevance +* @description 针对表【vp_ask_template_question_library(诊断问询意图问题库)】的数据库操作Service实现 +* @createDate 2023-11-03 11:13:26 +*/ +@Service +public class AskTemplateQuestionLibraryServiceImpl extends ServiceImpl + implements AskTemplateQuestionLibraryService{ + +} + + + + diff --git a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionServiceImpl.java b/virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionServiceImpl.java deleted file mode 100644 index a1ce81fb..00000000 --- a/virtual-patient-model/src/main/java/com/supervision/service/impl/AskTemplateQuestionServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.supervision.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.supervision.model.AskTemplateQuestion; -import com.supervision.service.AskTemplateQuestionService; -import com.supervision.mapper.AskTemplateQuestionMapper; -import org.springframework.stereotype.Service; - -/** -* @author flevance -* @description 针对表【vp_ask_template_question(诊断问询意图)】的数据库操作Service实现 -* @createDate 2023-10-27 10:05:55 -*/ -@Service -public class AskTemplateQuestionServiceImpl extends ServiceImpl - implements AskTemplateQuestionService{ - -} - - - - diff --git a/virtual-patient-model/src/main/java/com/supervision/service/impl/MedicalRecServiceImpl.java b/virtual-patient-model/src/main/java/com/supervision/service/impl/MedicalRecServiceImpl.java new file mode 100644 index 00000000..fa5c2149 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/service/impl/MedicalRecServiceImpl.java @@ -0,0 +1,22 @@ +package com.supervision.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.supervision.model.MedicalRec; +import com.supervision.service.MedicalRecService; +import com.supervision.mapper.MedicalRecMapper; +import org.springframework.stereotype.Service; + +/** +* @author flevance +* @description 针对表【vp_medical_rec(病历表)】的数据库操作Service实现 +* @createDate 2023-11-03 11:25:43 +*/ +@Service +public class MedicalRecServiceImpl extends ServiceImpl + implements MedicalRecService{ + +} + + + + diff --git a/virtual-patient-model/src/main/resources/mapper/AskDiseaseQuestionAnswerMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskDiseaseQuestionAnswerMapper.xml deleted file mode 100644 index 6a8e90ef..00000000 --- a/virtual-patient-model/src/main/resources/mapper/AskDiseaseQuestionAnswerMapper.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - id,patient_id,template_question_id, - code,description,question, - answer,create_user_id,create_time, - update_user_id,update_time - - diff --git a/virtual-patient-model/src/main/resources/mapper/AskDefaultQuestionAnswerMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml similarity index 60% rename from virtual-patient-model/src/main/resources/mapper/AskDefaultQuestionAnswerMapper.xml rename to virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml index 5a7a978f..5da28e5f 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskDefaultQuestionAnswerMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml @@ -2,14 +2,14 @@ - + - + - - - - + + + + @@ -17,8 +17,8 @@ - id,code,description, - question,answer,create_user_id, + id,patient_id,library_question_id, + answer,require_check,create_user_id, create_time,update_user_id,update_time diff --git a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml similarity index 76% rename from virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionMapper.xml rename to virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml index 5c8807fc..2d946087 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml @@ -2,13 +2,14 @@ - + - + - + + @@ -17,7 +18,7 @@ id,code,description, - question,create_user_id,create_time, - update_user_id,update_time + question,default_answer,create_user_id, + create_time,update_user_id,update_time diff --git a/virtual-patient-model/src/main/resources/mapper/MedicalRecMapper.xml b/virtual-patient-model/src/main/resources/mapper/MedicalRecMapper.xml new file mode 100644 index 00000000..3b07084b --- /dev/null +++ b/virtual-patient-model/src/main/resources/mapper/MedicalRecMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + id,no,patient_id, + patient_self_desc,symptoms,expect_diagnosis_result, + expect_disease_treatment_plan,primary_diagnosis,allergy_history, + previous_history,family_history,marriage_child_history + + diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/TestController.java b/virtual-patient-web/src/main/java/com/supervision/controller/TestController.java index 6e95fbdf..a7b3e38a 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/TestController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/TestController.java @@ -1,23 +1,13 @@ package com.supervision.controller; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.hash.Hash; import cn.hutool.crypto.digest.MD5; -import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; -import cn.hutool.poi.excel.ExcelReader; -import cn.hutool.poi.excel.ExcelUtil; import com.supervision.exception.BusinessException; -import com.supervision.model.AskDiseaseQuestionAnswer; -import com.supervision.model.AskTemplateQuestion; import com.supervision.model.ConfigPhysicalTool; -import com.supervision.service.AskDiseaseQuestionAnswerService; -import com.supervision.service.AskTemplateQuestionService; import com.supervision.service.ConfigPhysicalToolService; import lombok.RequiredArgsConstructor; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.*; @@ -96,38 +86,6 @@ public class TestController { return signServer; } - @PostMapping("saveQuestion") - @Transactional(rollbackFor = Exception.class) - public void saveQuestion() { - ExcelReader reader = ExcelUtil.getReader("/Users/flevance/Desktop/template.xlsx"); - List> read = reader.read(); - for (List readLine : read) { - String desc = (String) readLine.get(0); - String pinyin = PinyinUtil.getPinyin((String) readLine.get(0), "_"); - String question = (String) readLine.get(1); - String answer = (String) readLine.get(2); - String otherQuestionStr = (String) readLine.get(3); - - AskTemplateQuestion templateQuestion = new AskTemplateQuestion(); - templateQuestion.setCode("ask_" + pinyin); - templateQuestion.setDescription(desc); - List questionList = JSONUtil.toList(otherQuestionStr, String.class); - questionList.add(0, question); - templateQuestion.setQuestion(questionList); - templateQuestion.insert(); - - - AskDiseaseQuestionAnswer askDiseaseQuestionAnswer = new AskDiseaseQuestionAnswer(); - askDiseaseQuestionAnswer.setPatientId("1"); - askDiseaseQuestionAnswer.setTemplateQuestionId(templateQuestion.getId()); - askDiseaseQuestionAnswer.setAnswer(ListUtil.of(answer)); - askDiseaseQuestionAnswer.insert(); - - - } - - - } } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskAncillaryServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskAncillaryServiceImpl.java index 33ac6bbe..4f25834e 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskAncillaryServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskAncillaryServiceImpl.java @@ -26,6 +26,8 @@ public class AskAncillaryServiceImpl implements AskAncillaryService { private final DiagnosisAncillaryRecordService diagnosisAncillaryRecordService; + private final MedicalRecService medicalRecService; + @Override public List queryAncillaryItemList() { List list = ancillaryItemService.lambdaQuery().list(); @@ -42,7 +44,7 @@ public class AskAncillaryServiceImpl implements AskAncillaryService { // 首先根据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()) + DiseaseAncillary diseaseAncillary = diseaseAncillaryService.lambdaQuery().eq(DiseaseAncillary::getMedicalRecId, process.getMedicalRecId()).eq(DiseaseAncillary::getItemId, reqVO.getItemId()) .oneOpt().orElseGet(() -> { DiseaseAncillary get = new DiseaseAncillary(); get.setResult("无相关资讯"); 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 8e7306b2..e0f5f294 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 @@ -28,7 +28,9 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService private final DiagnosisPrimaryService diagnosisPrimaryService; - private final AskDiseaseQuestionAnswerService askDiseaseQuestionAnswerService; + private final AskPatientAnswerService askPatientAnswerService; + + private final MedicalRecService medicalRecService; private final DiagnosisQaRecordService diagnosisQaRecordService; @@ -68,11 +70,12 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService diagnosisResultResVO.setId(processId); Process process = processService.getById(processId); Patient patient = patientService.getById(process.getPatientId()); - List diseasesList = diseaseService.listByIds(patient.getDiseaseList()); + MedicalRec medicalRec = medicalRecService.getById(process.getMedicalRecId()); + List diseasesList = diseaseService.listByIds(medicalRec.getDiseaseList()); // 1.生成预期诊断结果 - diagnosisResultResVO.setExpertDiagnosisResult(creatExpertDiagnosisResult(diagnosisResult, patient, diseasesList)); + diagnosisResultResVO.setExpertDiagnosisResult(creatExpertDiagnosisResult(medicalRec, diagnosisResult, diseasesList)); // 2.生成初步诊断依据 - diagnosisResultResVO.setBasisPrimaryResultResVO(createBasisPrimaryResult(processId, diseasesList)); + diagnosisResultResVO.setBasisPrimaryResultResVO(createBasisPrimaryResult(patient, processId, diseasesList)); // 3.生成证实诊断依据 diagnosisResultResVO.setBasisConfirmResultResVO(createBasisConfirmResult(processId, diseasesList)); // 4.生成鉴别诊断依据 @@ -80,15 +83,15 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService // 5.全面检查-(暂无相关数据) 后面再看 diagnosisResultResVO.setFullCheck(null); // 6.处置方案 - diagnosisResultResVO.setDealPlan(createDealPlan(diagnosisResult, patient)); + diagnosisResultResVO.setDealPlan(createDealPlan(medicalRec, diagnosisResult, patient)); return diagnosisResultResVO; } - private DealPlanResVO createDealPlan(DiagnosisResult diagnosisResult, Patient patient) { + private DealPlanResVO createDealPlan(MedicalRec medicalRec, DiagnosisResult diagnosisResult, Patient patient) { DealPlanResVO dealPlanResVO = new DealPlanResVO(); dealPlanResVO.setUserTreatmentPlanType(diagnosisResult.getTreatmentPlanType()); dealPlanResVO.setUserTreatmentPlan(diagnosisResult.getTreatmentPlan()); - dealPlanResVO.setRealTreatmentPlan(patient.getDiseaseTreatmentPlan()); + dealPlanResVO.setRealTreatmentPlan(medicalRec.getExpectDiseaseTreatmentPlan()); return dealPlanResVO; } @@ -153,7 +156,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService return basisConfirmResultResVO; } - private BasisPrimaryResultResVO createBasisPrimaryResult(String processId, List diseasesList) { + private BasisPrimaryResultResVO createBasisPrimaryResult(Patient patient, String processId, List diseasesList) { BasisPrimaryResultResVO basisPrimaryResultResVO = new BasisPrimaryResultResVO(); basisPrimaryResultResVO.setPreliminaryDiagnosis(diseasesList.stream().map(Disease::getPreliminaryDiagnosis).collect(Collectors.toList())); // 根据record记录寻找符合初步诊断依据的项目 @@ -161,13 +164,11 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService List basisDiagnosisNodeResVOS = new ArrayList<>(); List qaRecordList = diagnosisQaRecordService.lambdaQuery().eq(DiagnosisQaRecord::getProcessId, processId).list(); if (CollectionUtil.isNotEmpty(qaRecordList)) { - Set questionAnswerIdSet = qaRecordList.stream().map(DiagnosisQaRecord::getQuestionAnswerId).collect(Collectors.toSet()); - List list = askDiseaseQuestionAnswerService.lambdaQuery() - .in(AskDiseaseQuestionAnswer::getId, questionAnswerIdSet) - .eq(AskDiseaseQuestionAnswer::getRequireCheck, 1) - .select(AskDiseaseQuestionAnswer::getId).list(); + List list = askPatientAnswerService.lambdaQuery() + .eq(AskPatientAnswer::getPatientId, patient.getId()) + .eq(AskPatientAnswer::getRequireCheck, 1).list(); // 获取必问的项目 - Set requireCheckIdSet = list.stream().map(AskDiseaseQuestionAnswer::getId).collect(Collectors.toSet()); + Set requireCheckIdSet = list.stream().map(AskPatientAnswer::getId).collect(Collectors.toSet()); List qaList = qaRecordList.stream().map(e -> { BasisDiagnosisNodeResVO node = new BasisDiagnosisNodeResVO(); node.setType(0); @@ -208,9 +209,12 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService } - private ExpertDiagnosisResultResVO creatExpertDiagnosisResult(DiagnosisResult diagnosisResult, Patient patient, List diseasesList) { + /** + * 预期诊断结果 + */ + private ExpertDiagnosisResultResVO creatExpertDiagnosisResult(MedicalRec medicalRec, DiagnosisResult diagnosisResult, List diseasesList) { ExpertDiagnosisResultResVO expertDiagnosisResultResVO = new ExpertDiagnosisResultResVO(); - expertDiagnosisResultResVO.setDiagnosis(patient.getExpectedDiagnosisResult()); + expertDiagnosisResultResVO.setDiagnosis(medicalRec.getExpectDiagnosisResult()); Set expertDiseaseIdSet = diseasesList.stream().map(Disease::getId).collect(Collectors.toSet()); List userDiagnosisDiseaseList = diseaseService.listByIds(diagnosisResult.getFinalDiagnosis()); // 用户的诊断 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 1b9ff141..b4b506cf 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 @@ -59,7 +59,7 @@ public class AskPhysicalServiceImpl implements AskPhysicalService { .oneOpt().orElseThrow(() -> new BusinessException("未找到对应部位")); locationId = location.getId(); } - DiseasePhysical result = diseasePhysicalService.lambdaQuery().eq(DiseasePhysical::getPatientId, process.getPatientId()) + DiseasePhysical result = diseasePhysicalService.lambdaQuery().eq(DiseasePhysical::getMedicalRecId, process.getMedicalRecId()) .eq(DiseasePhysical::getToolId, tool.getId()).eq(StrUtil.isNotBlank(locationId), DiseasePhysical::getLocationId, locationId).last("limit 1") .oneOpt() .orElseGet(() -> { 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 506eef7e..22d6aad7 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,14 +1,18 @@ package com.supervision.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import com.supervision.exception.BusinessException; +import com.supervision.model.AskPatientAnswer; +import com.supervision.model.AskTemplateQuestionLibrary; import com.supervision.model.DiagnosisQaRecord; import com.supervision.model.Process; import com.supervision.pojo.vo.TalkReqVO; import com.supervision.pojo.vo.TalkResultResVO; -import com.supervision.service.AskDefaultQuestionAnswerService; -import com.supervision.service.AskDiseaseQuestionAnswerService; +import com.supervision.service.AskPatientAnswerService; +import com.supervision.service.AskTemplateQuestionLibraryService; import com.supervision.service.ProcessService; import com.supervision.util.*; import com.supervision.service.AskService; @@ -31,9 +35,9 @@ public class AskServiceImpl implements AskService { private final ProcessService processService; - private final AskDiseaseQuestionAnswerService askDiseaseQuestionAnswerService; + private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService; - private final AskDefaultQuestionAnswerService askDefaultQuestionAnswerService; + private final AskPatientAnswerService askPatientAnswerService; @Override @@ -56,11 +60,17 @@ public class AskServiceImpl implements AskService { @Override @Transactional(rollbackFor = Exception.class) - public TalkResultResVO talk(TalkReqVO talkReqVO) throws IOException { + public TalkResultResVO talk(TalkReqVO talkReqVO) { // 根据processId找到对应的病人 Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程")); // 调用rasa获取文字内容 String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId()); + // 如果rasa没有识别出来,则返回默认值 + if (StrUtil.isBlank(rasaResult)) { + // 这里调用京东数字人接口首先根据token获取房间号 + String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); + HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); + } TalkResultResVO talkResultResVO = new TalkResultResVO(); // 这里校验,rasa回复的结果是不是action // 这里设置的模板,对于action的动作全部是用ancillary_ | tool_进行标记,详情看生成rasa的yml的代码:RasaServiceImpl.generateDomain @@ -77,42 +87,28 @@ public class AskServiceImpl implements AskService { return talkResultResVO; } } else { - // 语音消息,这时调用京东的接口进行播放操作 - // 这里调用京东数字人接口首先根据token获取房间号 String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); - // 区分 - List answerIdList = StrUtil.split(rasaResult, '_'); - String qaId = null; - String qaType = "miss"; - String answer = "您好,我没有听懂您说什么"; - if (answerIdList.size() > 1) { - if (rasaResult.startsWith("default_")) { - qaType = "default"; - List answerList = Optional.ofNullable(askDefaultQuestionAnswerService.getById(answerIdList.get(1)).getAnswer()) - .orElse(CollUtil.newArrayList("您好,我没有听懂您说什么")); - answer = answerList.get(new Random().nextInt(answerList.size())); - qaId = answerIdList.get(1); - - } else if (rasaResult.startsWith("disease_")) { - qaType = "disease"; - List answerList = Optional.ofNullable(askDiseaseQuestionAnswerService.getById(answerIdList.get(1)).getAnswer()) - .orElse(CollUtil.newArrayList("您好,我没有听懂您说什么")); - answer = answerList.get(new Random().nextInt(answerList.size())); - qaId = answerIdList.get(1); + AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); + if (ObjectUtil.isEmpty(library)) { + HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); + } else { + AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) + .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); + if (ObjectUtil.isEmpty(askPatientAnswer) || CollUtil.isEmpty(askPatientAnswer.getAnswer())) { + HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); + } else { + String resText = askPatientAnswer.getAnswer().get(RandomUtil.randomInt(0, askPatientAnswer.getAnswer().size())); + HumanUtil.textDriven(resText, roomId); + // 保存记录 + DiagnosisQaRecord record = new DiagnosisQaRecord(); + record.setProcessId(talkReqVO.getProcessId()); + record.setQuestionAnswerId(askPatientAnswer.getId()); + record.setQuestion(talkReqVO.getText()); + record.setAnswer(resText); + record.setCreateUserId(UserUtil.getUser().getId()); + record.insert(); } } - // 然后这里进行播放 - // 这里应该从对话中取结果 - HumanUtil.textDriven(rasaResult, roomId); - // 保存记录 - DiagnosisQaRecord record = new DiagnosisQaRecord(); - record.setProcessId(talkReqVO.getProcessId()); - record.setQuestionAnswerType(qaType); - record.setQuestionAnswerId(qaId); - record.setQuestion(talkReqVO.getText()); - record.setAnswer(answer); - record.setCreateUserId(UserUtil.getUser().getId()); - record.insert(); } talkResultResVO.setType(1); return talkResultResVO; diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java index ed61af87..29e70f80 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java @@ -7,15 +7,12 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONUtil; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.supervision.domain.GlobalResult; import com.supervision.exception.BusinessException; import com.supervision.model.*; -import com.supervision.pojo.paddlespeech.res.PaddleSpeechResDTO; -import com.supervision.pojo.paddlespeech.res.TtsResultDTO; import com.supervision.pojo.rasa.train.DomainYmlTemplate; import com.supervision.pojo.rasa.train.NluYmlTemplate; import com.supervision.pojo.rasa.train.QuestionAnswerDTO; @@ -43,16 +40,13 @@ import java.util.zip.ZipOutputStream; @RequiredArgsConstructor public class RasaServiceImpl implements RasaService { - private final AskDefaultQuestionAnswerService askDefaultQuestionAnswerService; - - private final AskDiseaseQuestionAnswerService askDiseaseQuestionAnswerService; - - private final AskTemplateQuestionService askTemplateQuestionService; - private final ConfigPhysicalToolService configPhysicalToolService; private final ConfigAncillaryItemService configAncillaryItemService; + private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService; + + private static final ObjectMapper objectMapper = new ObjectMapper(); @Value("${rasa.base-url}${rasa.saveRasaFile}") @@ -114,53 +108,20 @@ public class RasaServiceImpl implements RasaService { Map ymalFileMap) { // 首先生成根据意图查找到nlu文件 List nluList = new ArrayList<>(); + // 默认意图 - List defaultQuestionAnswerList = askDefaultQuestionAnswerService.lambdaQuery().isNotNull(AskDefaultQuestionAnswer::getAnswer).list(); + List askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.lambdaQuery().list(); // 生成默认意图的nlu - for (AskDefaultQuestionAnswer defaultQA : defaultQuestionAnswerList) { - if (CollUtil.isNotEmpty(defaultQA.getQuestion()) && CollUtil.isNotEmpty(defaultQA.getAnswer())) { - // 开始生成 - NluYmlTemplate.Nlu nlu = new NluYmlTemplate.Nlu(); - // 拼接格式:code_id(防止重复) - String intentCode = defaultQA.getCode() + "_" + defaultQA.getId(); - nlu.setIntent(intentCode); - nlu.setExamples(defaultQA.getQuestion()); - nluList.add(nlu); - // 添加到map中,key为意图编码,value为意图ID - intentCodeAndIdMap.put(intentCode, new QuestionAnswerDTO(defaultQA.getQuestion(), CollUtil.newArrayList("default_" + defaultQA.getId()), defaultQA.getDescription())); - } - } - // 然后处理该疾病对应的意图 - List diseaseQuestionAnswerList = askDiseaseQuestionAnswerService.lambdaQuery() - .eq(AskDiseaseQuestionAnswer::getPatientId, patientId).list(); - // 使用通用模板的 - Map templateQuestionMap = new HashMap<>(); - // 根据默认意图找到所有的问题 - if (CollUtil.isNotEmpty(diseaseQuestionAnswerList)) { - // 首先找到使用通用模板的问题 - List templateQuestionList = diseaseQuestionAnswerList.stream() - .filter(e -> StrUtil.isNotBlank(e.getTemplateQuestionId())).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(templateQuestionList)) { - Set templateQuestionIdList = templateQuestionList.stream().map(AskDiseaseQuestionAnswer::getTemplateQuestionId).collect(Collectors.toSet()); - List list = askTemplateQuestionService.lambdaQuery().in(AskTemplateQuestion::getId, templateQuestionIdList).list(); - templateQuestionMap = list.stream().collect(Collectors.toMap(AskTemplateQuestion::getId, Function.identity())); - } - } - // 这里开始遍历 - for (AskDiseaseQuestionAnswer askDiseaseQuestionAnswer : diseaseQuestionAnswerList) { - // 如果走模板的问题 - if (StrUtil.isNotBlank(askDiseaseQuestionAnswer.getTemplateQuestionId()) && templateQuestionMap.containsKey(askDiseaseQuestionAnswer.getTemplateQuestionId())) { - AskTemplateQuestion askTemplateQuestion = templateQuestionMap.get(askDiseaseQuestionAnswer.getTemplateQuestionId()); - // 开始生成 - NluYmlTemplate.Nlu nlu = new NluYmlTemplate.Nlu(); - // 拼接格式:code_answerId(防止重复) - String intentCode = askTemplateQuestion.getCode() + "_" + askDiseaseQuestionAnswer.getId(); - nlu.setIntent(intentCode); - nlu.setExamples(askTemplateQuestion.getQuestion()); - nluList.add(nlu); - intentCodeAndIdMap.put(intentCode, new QuestionAnswerDTO(askTemplateQuestion.getQuestion(), CollUtil.newArrayList("disease_" + askDiseaseQuestionAnswer.getId()), askTemplateQuestion.getDescription())); - - } + for (AskTemplateQuestionLibrary questionLibrary : askTemplateQuestionLibraryList) { + // 开始生成 + NluYmlTemplate.Nlu nlu = new NluYmlTemplate.Nlu(); + // 拼接格式:code_id(防止重复) + String intentCode = questionLibrary.getCode() + "_" + questionLibrary.getId(); + nlu.setIntent(intentCode); + nlu.setExamples(questionLibrary.getQuestion()); + nluList.add(nlu); + // 添加到map中,key为意图编码,value为意图ID + intentCodeAndIdMap.put(intentCode, new QuestionAnswerDTO(questionLibrary.getQuestion(), CollUtil.newArrayList( questionLibrary.getId()), questionLibrary.getDescription())); } // 这里处理呼出的问题(code和问题不能为空) From 3cc10c4e87e3606a0e59f1eb1a55627a5c7eb438 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 13:15:08 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/AskPatientAnswerMapper.xml | 3 ++- .../AskTemplateQuestionLibraryMapper.xml | 3 ++- .../mapper/ConfigPhysicalToolMapper.xml | 2 +- .../mapper/DiagnosisQaRecordMapper.xml | 1 - .../mapper/DiseaseAncillaryMapper.xml | 2 +- .../mapper/DiseasePhysicalMapper.xml | 2 +- .../main/resources/mapper/PatientMapper.xml | 4 ---- .../main/resources/mapper/ProcessMapper.xml | 20 ++++++++++--------- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml index 5da28e5f..8e775c7f 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskPatientAnswerMapper.xml @@ -8,7 +8,8 @@ - + diff --git a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml index 2d946087..3cbee9db 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml @@ -8,7 +8,8 @@ - + diff --git a/virtual-patient-model/src/main/resources/mapper/ConfigPhysicalToolMapper.xml b/virtual-patient-model/src/main/resources/mapper/ConfigPhysicalToolMapper.xml index 131ecc9c..a4dd7844 100644 --- a/virtual-patient-model/src/main/resources/mapper/ConfigPhysicalToolMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/ConfigPhysicalToolMapper.xml @@ -11,7 +11,7 @@ - diff --git a/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml b/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml index 4be5869a..a7d1c3df 100644 --- a/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml @@ -7,7 +7,6 @@ - diff --git a/virtual-patient-model/src/main/resources/mapper/DiseaseAncillaryMapper.xml b/virtual-patient-model/src/main/resources/mapper/DiseaseAncillaryMapper.xml index ab83076c..11f90c9a 100644 --- a/virtual-patient-model/src/main/resources/mapper/DiseaseAncillaryMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/DiseaseAncillaryMapper.xml @@ -6,7 +6,7 @@ - + diff --git a/virtual-patient-model/src/main/resources/mapper/DiseasePhysicalMapper.xml b/virtual-patient-model/src/main/resources/mapper/DiseasePhysicalMapper.xml index b364c4e1..de57c644 100644 --- a/virtual-patient-model/src/main/resources/mapper/DiseasePhysicalMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/DiseasePhysicalMapper.xml @@ -6,7 +6,7 @@ - + diff --git a/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml b/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml index 73e3e424..60d33746 100644 --- a/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml @@ -12,10 +12,6 @@ - - - diff --git a/virtual-patient-model/src/main/resources/mapper/ProcessMapper.xml b/virtual-patient-model/src/main/resources/mapper/ProcessMapper.xml index 019aeed6..4e60c339 100644 --- a/virtual-patient-model/src/main/resources/mapper/ProcessMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/ProcessMapper.xml @@ -5,18 +5,20 @@ - - - - - - - - + + + + + + + + + - id,patient_id,user_id, + id + ,patient_id,user_id, status,create_user_id,create_time, update_user_id,update_time From ecc7ce5412b06e058c3a954640b83497e5a262a7 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 13:21:26 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AskTemplateQuestionLibraryMapper.xml | 24 ++++++++++--------- .../service/impl/AskServiceImpl.java | 14 +++++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml index 3cbee9db..ca9fd436 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml @@ -5,20 +5,22 @@ - - - - - - - - - + + + + + + + + + - id,code,description, + id + ,code,description, question,default_answer,create_user_id, create_time,update_user_id,update_time 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 22d6aad7..47453d8f 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 @@ -92,6 +92,20 @@ public class AskServiceImpl implements AskService { if (ObjectUtil.isEmpty(library)) { HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); } else { + // 首先看看default里面是不是存在,如果存在,就从default里面去找 + if (CollUtil.isNotEmpty(library.getDefaultAnswer())) { + String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size())); + HumanUtil.textDriven(resText, roomId); + // 保存记录 + DiagnosisQaRecord record = new DiagnosisQaRecord(); + record.setProcessId(talkReqVO.getProcessId()); + // 注意,这里如果有默认回答,回答的结果是默认结果ID + record.setQuestionAnswerId(library.getId()); + record.setQuestion(talkReqVO.getText()); + record.setAnswer(resText); + record.setCreateUserId(UserUtil.getUser().getId()); + record.insert(); + } AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); if (ObjectUtil.isEmpty(askPatientAnswer) || CollUtil.isEmpty(askPatientAnswer.getAnswer())) { From acc0157d6de5175f5bf121dc94536d6dcf5b9396 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 13:25:25 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/supervision/model/DiagnosisQaRecord.java | 7 +++++-- .../src/main/resources/mapper/DiagnosisQaRecordMapper.xml | 3 ++- .../java/com/supervision/service/impl/AskServiceImpl.java | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java b/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java index d4e996d4..68607e7f 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/DiagnosisQaRecord.java @@ -32,11 +32,14 @@ public class DiagnosisQaRecord extends Model implements Seria @ApiModelProperty("诊断进程ID") private String processId; + @ApiModelProperty("问答类型:default,patient") + private String answerType; + /** * 问题答案表ID */ - @ApiModelProperty("问题答案表ID") - private String questionAnswerId; + @ApiModelProperty("问题答案表ID,default:vp_ask_template_question_library的主键,patient:vp_ask_patient_answer主键") + private String answerId; /** * 问题 diff --git a/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml b/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml index a7d1c3df..5be2a328 100644 --- a/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/DiagnosisQaRecordMapper.xml @@ -7,7 +7,8 @@ - + + 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 47453d8f..561c5732 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 @@ -99,8 +99,9 @@ public class AskServiceImpl implements AskService { // 保存记录 DiagnosisQaRecord record = new DiagnosisQaRecord(); record.setProcessId(talkReqVO.getProcessId()); + record.setAnswerType("default"); // 注意,这里如果有默认回答,回答的结果是默认结果ID - record.setQuestionAnswerId(library.getId()); + record.setAnswerId(library.getId()); record.setQuestion(talkReqVO.getText()); record.setAnswer(resText); record.setCreateUserId(UserUtil.getUser().getId()); @@ -116,7 +117,8 @@ public class AskServiceImpl implements AskService { // 保存记录 DiagnosisQaRecord record = new DiagnosisQaRecord(); record.setProcessId(talkReqVO.getProcessId()); - record.setQuestionAnswerId(askPatientAnswer.getId()); + record.setAnswerType("patient"); + record.setAnswerId(askPatientAnswer.getId()); record.setQuestion(talkReqVO.getText()); record.setAnswer(resText); record.setCreateUserId(UserUtil.getUser().getId()); From 074adec6aaa7bf728124a7e97e6dc56e94685f3a Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 13:39:08 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/AskDiagnosisResultServiceImpl.java | 2 +- .../service/impl/AskServiceImpl.java | 88 +++++++++++++------ 2 files changed, 61 insertions(+), 29 deletions(-) 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 e0f5f294..c2b9cdbd 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 @@ -174,7 +174,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService node.setType(0); node.setRecordName(e.getQuestion()); node.setRecordId(e.getId()); - node.setCorrect(requireCheckIdSet.contains(e.getQuestionAnswerId()) ? 1 : 0); + node.setCorrect(requireCheckIdSet.contains(e.getAnswerId()) ? 1 : 0); return node; }).collect(Collectors.toList()); 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 561c5732..ae257566 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 @@ -76,6 +76,7 @@ public class AskServiceImpl implements AskService { // 这里设置的模板,对于action的动作全部是用ancillary_ | tool_进行标记,详情看生成rasa的yml的代码:RasaServiceImpl.generateDomain // ancillary_ | tool_ if (rasaResult.startsWith("ancillary_") || rasaResult.startsWith("tool_")) { + log.info("呼出语句:{}", rasaResult); List actionList = StrUtil.split(rasaResult, '_'); if (actionList.size() > 1) { ActionDTO actionDTO = new ActionDTO(); @@ -90,39 +91,70 @@ public class AskServiceImpl implements AskService { String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); if (ObjectUtil.isEmpty(library)) { + log.info("{}:未从问题库中找到,回答未识别语句", rasaResult); HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); } else { - // 首先看看default里面是不是存在,如果存在,就从default里面去找 - if (CollUtil.isNotEmpty(library.getDefaultAnswer())) { - String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size())); - 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(); - } AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getPatientId, process.getPatientId()) .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); - if (ObjectUtil.isEmpty(askPatientAnswer) || CollUtil.isEmpty(askPatientAnswer.getAnswer())) { - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); + // 如果没有找到回答,去默认回答里面看看有没有 + if (ObjectUtil.isEmpty(askPatientAnswer)) { + log.info("{}:病历配置的回答为空,尝试回答默认答案", rasaResult); + // 首先看看default里面是不是存在,如果存在,就从default里面去找 + if (CollUtil.isNotEmpty(library.getDefaultAnswer())) { + String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size())); + 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(); + log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText()); + } else { + log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult); + HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); + } } else { - String resText = askPatientAnswer.getAnswer().get(RandomUtil.randomInt(0, askPatientAnswer.getAnswer().size())); - HumanUtil.textDriven(resText, roomId); - // 保存记录 - DiagnosisQaRecord record = new DiagnosisQaRecord(); - record.setProcessId(talkReqVO.getProcessId()); - record.setAnswerType("patient"); - record.setAnswerId(askPatientAnswer.getId()); - record.setQuestion(talkReqVO.getText()); - record.setAnswer(resText); - record.setCreateUserId(UserUtil.getUser().getId()); - record.insert(); + if (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); + } + + } else { + String resText = askPatientAnswer.getAnswer().get(RandomUtil.randomInt(0, askPatientAnswer.getAnswer().size())); + log.info("{}:找到了病历配置的回答语句,回答内容:{}", rasaResult, resText); + HumanUtil.textDriven(resText, roomId); + // 保存记录 + DiagnosisQaRecord record = new DiagnosisQaRecord(); + record.setProcessId(talkReqVO.getProcessId()); + record.setAnswerType("patient"); + record.setAnswerId(askPatientAnswer.getId()); + record.setQuestion(talkReqVO.getText()); + record.setAnswer(resText); + record.setCreateUserId(UserUtil.getUser().getId()); + record.insert(); + } + } } } From c01923c472aafae0bbfd125697ae6d6af2bb6fa5 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 13:42:10 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/supervision/service/impl/AskServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 ae257566..cfdb0d30 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 @@ -98,7 +98,7 @@ public class AskServiceImpl implements AskService { .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); // 如果没有找到回答,去默认回答里面看看有没有 if (ObjectUtil.isEmpty(askPatientAnswer)) { - log.info("{}:病历配置的回答为空,尝试回答默认答案", rasaResult); + log.info("{}:病历配置的回答:{}:为空,尝试回答默认答案", rasaResult, askPatientAnswer.getId()); // 首先看看default里面是不是存在,如果存在,就从default里面去找 if (CollUtil.isNotEmpty(library.getDefaultAnswer())) { String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size())); @@ -120,10 +120,10 @@ public class AskServiceImpl implements AskService { } } else { if (CollUtil.isEmpty(askPatientAnswer.getAnswer())) { - log.info("{}:病历配置的回答不为空,但在获取的时候,答案为空,尝试回复默认语句", rasaResult); + log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,尝试回复默认语句", rasaResult, askPatientAnswer.getId()); if (CollUtil.isNotEmpty(library.getDefaultAnswer())) { String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size())); - log.info("{}:病历配置的回答不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, resText); + log.info("{}:病历配置的回答:{}:为空不为空不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, askPatientAnswer.getId(), resText); HumanUtil.textDriven(resText, roomId); // 保存记录 DiagnosisQaRecord record = new DiagnosisQaRecord(); @@ -136,13 +136,13 @@ public class AskServiceImpl implements AskService { record.setCreateUserId(UserUtil.getUser().getId()); record.insert(); } else { - log.info("{}:病历配置的回答不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult); + log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult, askPatientAnswer.getId()); HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); } } else { String resText = askPatientAnswer.getAnswer().get(RandomUtil.randomInt(0, askPatientAnswer.getAnswer().size())); - log.info("{}:找到了病历配置的回答语句,回答内容:{}", rasaResult, resText); + log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText); HumanUtil.textDriven(resText, roomId); // 保存记录 DiagnosisQaRecord record = new DiagnosisQaRecord(); From 38294e97d144739dd23cb72189523218a6e96c3d Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 14:02:35 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/supervision/model/Disease.java | 5 +++++ .../src/main/resources/mapper/DiseaseMapper.xml | 10 ++++++++-- .../supervision/controller/AskProcessController.java | 6 +++--- .../com/supervision/service/AskProcessService.java | 2 +- .../service/impl/AskProcessServiceImpl.java | 3 ++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/virtual-patient-model/src/main/java/com/supervision/model/Disease.java b/virtual-patient-model/src/main/java/com/supervision/model/Disease.java index a5e1796c..d7017a9a 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/Disease.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/Disease.java @@ -44,7 +44,12 @@ public class Disease implements Serializable { @ApiModelProperty("状态 0未训练 1已训练") private Integer status; + @ApiModelProperty("疾病类型 0单一疾病 1符合疾病") + private Integer diseaseType; + @ApiModelProperty("来源的单一疾病ID-用于初步诊断判定使用") + @TableField(typeHandler = StringListTypeHandler.class) + private List containsDiseaseId; /** * 初步诊断依据 */ diff --git a/virtual-patient-model/src/main/resources/mapper/DiseaseMapper.xml b/virtual-patient-model/src/main/resources/mapper/DiseaseMapper.xml index 77952b04..cf6b7786 100644 --- a/virtual-patient-model/src/main/resources/mapper/DiseaseMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/DiseaseMapper.xml @@ -9,6 +9,11 @@ + + + @@ -20,8 +25,9 @@ - id,disease_name - ,code,status, + id + ,disease_name + ,code,status,diseaseType,containsDiseaseId,standardQuestionLibrary, expected_diagnosis_result,preliminary_diagnosis,confirming_diagnosis, basis_identification,disease_treatment_plan,other,create_user_id, create_time,update_user_id,update_time diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java index 71d53617..bbc4aa67 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java @@ -24,14 +24,14 @@ public class AskProcessController { @ApiOperation("生成诊断流程任务") @GetMapping("creatDiagnosisProcess") - public Process creatDiagnosisProcess(@ApiParam("病人ID") String patientId) { + public Process creatDiagnosisProcess(@ApiParam("病人ID") String patientId, String medicalId) { User user = UserUtil.getUser(); - return askProcessService.creatDiagnosisProcess(patientId, user); + return askProcessService.creatDiagnosisProcess(patientId, medicalId, user); } @ApiOperation("查询用户正在诊断中的诊断记录") @GetMapping("queryUserProcess") - public List queryUserProcess(String userId){ + public List queryUserProcess(String userId) { return askProcessService.queryUserProcess(userId); } } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/AskProcessService.java b/virtual-patient-web/src/main/java/com/supervision/service/AskProcessService.java index fbd5759a..7aed4d27 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/AskProcessService.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/AskProcessService.java @@ -7,7 +7,7 @@ import java.util.List; public interface AskProcessService { - Process creatDiagnosisProcess(String patientId, User user); + Process creatDiagnosisProcess(String patientId,String medicalId, User user); List queryUserProcess(String userId); diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskProcessServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskProcessServiceImpl.java index eacde7d5..d1157327 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskProcessServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskProcessServiceImpl.java @@ -16,9 +16,10 @@ public class AskProcessServiceImpl implements AskProcessService { private final ProcessService processService; @Override - public Process creatDiagnosisProcess(String patientId, User user) { + public Process creatDiagnosisProcess(String patientId,String medicalId, User user) { Process process = new Process(); process.setPatientId(patientId); + process.setMedicalRecId(medicalId); process.setUserId(user.getId()); process.setStatus(0); process.setCreateUserId(user.getId()); From 018c97712f5164f90a4f27b0cf0eac807c312684 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 14:29:24 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supervision/controller/UserController.java | 15 +++++++-------- .../java/com/supervision/pojo/vo/LoginReqVO.java | 10 ++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 virtual-patient-web/src/main/java/com/supervision/pojo/vo/LoginReqVO.java diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/UserController.java b/virtual-patient-web/src/main/java/com/supervision/controller/UserController.java index 6a017d6a..a8633904 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/UserController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/UserController.java @@ -5,14 +5,13 @@ import cn.hutool.json.JSONUtil; import com.supervision.domain.UserInfo; import com.supervision.exception.BusinessException; import com.supervision.model.User; +import com.supervision.pojo.vo.LoginReqVO; import com.supervision.service.UserService; import com.supervision.util.TokenUtil; 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; +import org.springframework.web.bind.annotation.*; import java.util.Optional; @@ -25,16 +24,16 @@ public class UserController { private final UserService userService; @ApiOperation("登录") - @GetMapping("login") - public String login(String userAccount, String password) { - if (!StrUtil.isAllNotBlank(userAccount, password)) { + @PostMapping("login") + public String login(@RequestBody LoginReqVO reqVO) { + if (!StrUtil.isAllNotBlank(reqVO.getUserAccount(), reqVO.getPassword())) { throw new BusinessException("用户名不能为空"); } - Optional user = userService.lambdaQuery().eq(User::getAccount, userAccount).last("limit 1").oneOpt(); + Optional user = userService.lambdaQuery().eq(User::getAccount, reqVO.getUserAccount()).last("limit 1").oneOpt(); if (!user.isPresent()) { throw new BusinessException("未找到用户"); } - if (!user.get().getPassword().equals(password)) { + if (!user.get().getPassword().equals(reqVO.getPassword())) { throw new BusinessException("密码错误"); } return TokenUtil.creatToken(JSONUtil.toJsonStr(user.get())); diff --git a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/LoginReqVO.java b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/LoginReqVO.java new file mode 100644 index 00000000..4541d567 --- /dev/null +++ b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/LoginReqVO.java @@ -0,0 +1,10 @@ +package com.supervision.pojo.vo; + +import lombok.Data; + +@Data +public class LoginReqVO { + + private String userAccount; + private String password; +} From 8f8114764bfc2b648937e42cda68be398c6b822a Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 3 Nov 2023 17:00:18 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supervision/config/JwtInterceptor.java | 28 +++++++++++++++---- .../com/supervision/config/Knife4jConfig.java | 2 -- .../com/supervision/config/WebConfig.java | 2 +- .../com/supervision/util/SpringBeanUtil.java | 0 .../java/com/supervision/model/Patient.java | 15 ++++++++-- .../main/resources/mapper/PatientMapper.xml | 5 +++- .../controller/AskProcessController.java | 2 +- 7 files changed, 41 insertions(+), 13 deletions(-) rename {virtual-patient-web => virtual-patient-common}/src/main/java/com/supervision/util/SpringBeanUtil.java (100%) diff --git a/virtual-patient-common/src/main/java/com/supervision/config/JwtInterceptor.java b/virtual-patient-common/src/main/java/com/supervision/config/JwtInterceptor.java index f30dae65..9a0c600d 100644 --- a/virtual-patient-common/src/main/java/com/supervision/config/JwtInterceptor.java +++ b/virtual-patient-common/src/main/java/com/supervision/config/JwtInterceptor.java @@ -7,26 +7,37 @@ import cn.hutool.jwt.JWT; import cn.hutool.jwt.JWTUtil; import com.supervision.domain.UserInfo; import com.supervision.exception.BusinessException; +import com.supervision.util.SpringBeanUtil; +import com.supervision.util.TokenUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; @Slf4j public class JwtInterceptor implements HandlerInterceptor { + @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { //请求消息头获取用户ID String token = request.getHeader("token"); - // 如果是开发环境,不获取token - if (StrUtil.isBlank(token)) { - throw new BusinessException("当前用户未登录"); + if (StrUtil.isBlank(token) ) { + // 如果是swagger来的接口,说明这里是测试的,会伪造一个用户 + if (StrUtil.isNotBlank(request.getHeader("Knife4j-Gateway-Code"))){ + token = devActiveUser(); + }else { + throw new BusinessException("当前用户未登录"); + } } + JWT jwt = JWTUtil.parseToken(token); // 校验token是否过期,如果过期了,需要提示过期重新登录 checkTokenExpire(jwt); @@ -46,7 +57,6 @@ public class JwtInterceptor implements HandlerInterceptor { Object expireTime = jwt.getPayload("expireTime"); long l = Long.parseLong(String.valueOf(expireTime)); // 校验是否比当前时间大 - System.out.println(l); long currentTimeMillis = System.currentTimeMillis(); if (currentTimeMillis > l) { throw new BusinessException("用户登录已过期,请重新登录"); @@ -62,6 +72,14 @@ public class JwtInterceptor implements HandlerInterceptor { } } + private String devActiveUser(){ + Map map = new HashMap<>(); + map.put("id","1"); + map.put("account","test"); + map.put("name","测试账户"); + return TokenUtil.creatToken(JSONUtil.toJsonStr(map)); + } + private void clearAuth() { ThreadCache.USER.remove(); } diff --git a/virtual-patient-common/src/main/java/com/supervision/config/Knife4jConfig.java b/virtual-patient-common/src/main/java/com/supervision/config/Knife4jConfig.java index f4274756..a9ff6873 100644 --- a/virtual-patient-common/src/main/java/com/supervision/config/Knife4jConfig.java +++ b/virtual-patient-common/src/main/java/com/supervision/config/Knife4jConfig.java @@ -10,8 +10,6 @@ */ package com.supervision.config; -import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; -import io.swagger.annotations.Api; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.bind.annotation.RestController; 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 45b32668..66a6c430 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 @@ -30,7 +30,7 @@ public class WebConfig implements WebMvcConfigurer { paths.add("/favicon.ico"); paths.add("/user/login"); // 开发环境,放开不校验token.每次修改这里需要重启(热部署不行) - paths.add("/**"); +// paths.add("/**"); return paths; } } diff --git a/virtual-patient-web/src/main/java/com/supervision/util/SpringBeanUtil.java b/virtual-patient-common/src/main/java/com/supervision/util/SpringBeanUtil.java similarity index 100% rename from virtual-patient-web/src/main/java/com/supervision/util/SpringBeanUtil.java rename to virtual-patient-common/src/main/java/com/supervision/util/SpringBeanUtil.java diff --git a/virtual-patient-model/src/main/java/com/supervision/model/Patient.java b/virtual-patient-model/src/main/java/com/supervision/model/Patient.java index 5e4b4682..08acdc55 100644 --- a/virtual-patient-model/src/main/java/com/supervision/model/Patient.java +++ b/virtual-patient-model/src/main/java/com/supervision/model/Patient.java @@ -35,10 +35,10 @@ public class Patient implements Serializable { private String name; /** - * 性别 0男 1女 + * 性别 */ - @ApiModelProperty("性别 0男 1女") - private Integer gender; + @ApiModelProperty("性别") + private String gender; /** * 病人年龄 @@ -64,6 +64,15 @@ public class Patient implements Serializable { @ApiModelProperty("体重") private BigDecimal weight; + @ApiModelProperty("婚姻") + private String marriage; + + @ApiModelProperty("职业") + private String profession; + + @ApiModelProperty("地址") + private String address; + /** * 创建人ID */ diff --git a/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml b/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml index 60d33746..db1c29ba 100644 --- a/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/PatientMapper.xml @@ -12,6 +12,9 @@ + + + @@ -21,7 +24,7 @@ id ,name,gender, - age,symptoms,height, + age,symptoms,height,address,marriage,profession, weight,disease_list,create_user_id, create_time,update_user_id,update_time diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java index bbc4aa67..28fe645c 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskProcessController.java @@ -24,7 +24,7 @@ public class AskProcessController { @ApiOperation("生成诊断流程任务") @GetMapping("creatDiagnosisProcess") - public Process creatDiagnosisProcess(@ApiParam("病人ID") String patientId, String medicalId) { + public Process creatDiagnosisProcess(@ApiParam("病人ID") String patientId,@ApiParam("病历ID") String medicalId) { User user = UserUtil.getUser(); return askProcessService.creatDiagnosisProcess(patientId, medicalId, user); }