1、新增病例提示词

2、新增生成数字人问诊回复视频接口
jinan_uat_by_release_3.0.0
longbao 6 months ago
parent 55461f6800
commit 527c676c2a

@ -1,4 +1,4 @@
package com.supervision.manage.human; package com.supervision.manage.controller.human;
import com.supervision.manage.service.HumanManageService; import com.supervision.manage.service.HumanManageService;
import com.supervision.model.Human; import com.supervision.model.Human;
@ -6,6 +6,7 @@ import com.supervision.vo.manage.HumanCreateReqVo;
import com.supervision.vo.manage.HumanReqVo; import com.supervision.vo.manage.HumanReqVo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -23,9 +24,19 @@ public class HumanManageController {
@Operation(summary = "新增数字人") @Operation(summary = "新增数字人")
@PostMapping(value = "/createHuman",consumes = "multipart/form-data") @PostMapping(value = "/createHuman", consumes = "multipart/form-data")
public boolean createHuman(@RequestParam("file") MultipartFile imageFile, String medicalId) { public boolean createHuman(@RequestParam("file") MultipartFile imageFile, String medicalId) {
return humanManageService.createHuman(imageFile, medicalId); return humanManageService.createHuman(imageFile, medicalId);
} }
@Operation(summary = "生成数字人问诊问题回复视频")
@PostMapping(value = "/createHumanVideo", consumes = "multipart/form-data")
public boolean createHuman(@RequestParam("file") MultipartFile imageFile,
@RequestParam("file") MultipartFile videoFile,
String answer,
HttpServletResponse response) throws Exception {
return humanManageService.createHumanAnswerVideo(imageFile, videoFile, answer, response);
}
} }

@ -0,0 +1,56 @@
package com.supervision.manage.controller.medicalrec;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.manage.service.MedicalManageAiDicService;
import com.supervision.vo.manage.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Authorlongbao
* @Date2024/11/14 9:28
* @Description:
*/
@Tag(name = "病例提示词管理")
@RestController
@RequestMapping("/medicalRecAiManage")
@RequiredArgsConstructor
public class MedicalAiDicController {
@Autowired
private MedicalManageAiDicService medicalAiDicService;
@Operation(summary = "分页查询")
@GetMapping("/query")
public IPage<MedicalRecPageResVO> queryMedicalRecManagePage(@Parameter(name = "attribute_name", description = "属性名称") String attributeName,
Integer pageNum, Integer pageSize) {
return medicalAiDicService.queryPage(attributeName, pageNum, pageSize);
}
@Operation(summary = "创建")
@PostMapping("/create")
public void createMedicalRec(@RequestBody MedicalRecAiManageCreateVO reqVO) {
medicalAiDicService.create(reqVO);
}
@Operation(summary = "修改")
@PutMapping("/modify")
public void modifyMedicalRec(@RequestBody MedicalRecAiManageUpdateVO reqVO) {
medicalAiDicService.modify(reqVO);
}
@Operation(summary = "删除")
@GetMapping("/delete")
public void deleteMedicalRec(String id) {
medicalAiDicService.delete(id);
}
}

@ -1,10 +1,13 @@
package com.supervision.manage.controller.medicalrec; package com.supervision.manage.controller.medicalrec;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.manage.pojo.vo.*; import com.supervision.manage.pojo.vo.*;
import com.supervision.manage.service.MedicalRecManageService; import com.supervision.manage.service.MedicalRecManageService;
import com.supervision.model.Disease; import com.supervision.model.Disease;
import com.supervision.model.MedicalRec; import com.supervision.model.MedicalRec;
import com.supervision.model.MedicalRecAi;
import com.supervision.vo.manage.*; import com.supervision.vo.manage.*;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -123,7 +126,6 @@ public class MedicalRecManageController {
@Operation(summary = "查询病例默认问题") @Operation(summary = "查询病例默认问题")
@GetMapping("/queryMedicalDefaultAnswer") @GetMapping("/queryMedicalDefaultAnswer")
public List<MedicalRecQaVO> queryMedicalDefaultAnswer(@Parameter(name = "medicalRecId", description = "病例id") String medicalRecId) { public List<MedicalRecQaVO> queryMedicalDefaultAnswer(@Parameter(name = "medicalRecId", description = "病例id") String medicalRecId) {
return medicalRecManageService.queryMedicalDefaultAnswer(medicalRecId); return medicalRecManageService.queryMedicalDefaultAnswer(medicalRecId);
} }
@ -151,11 +153,19 @@ public class MedicalRecManageController {
} }
@Operation(summary = "查询病例提示词属性")
@GetMapping("/queryMedicalPromptStats")
public MedicalPromptStatsResVo queryMedicalPromptStats() {
return medicalRecManageService.queryMedicalPromptStats();
}
@Operation(summary = "生成病历模型提示词") @Operation(summary = "生成病历模型提示词")
@PutMapping("/uploadMedicalAiById") @PutMapping("/uploadMedicalAiById")
public void uploadMedicalAi(@Parameter(name = "medicalRecId", description = "病例id") String medicalRecId, public void uploadMedicalAi(@RequestBody MedicalRecCreateAiManageVO medicalRecAi) {
@Parameter(name = "medicalRecAi", description = "提示词") String medicalRecAi) throws Exception { medicalRecManageService.uploadMedicalAi(medicalRecAi);
medicalRecManageService.uploadMedicalAi(medicalRecId, medicalRecAi);
} }

@ -0,0 +1,10 @@
package com.supervision.manage.pojo.ai;
import lombok.Data;
@Data
public class AiMangeTalkAnswerDTO {
private String answer;
}

@ -0,0 +1,22 @@
package com.supervision.manage.pojo.vo;
import com.supervision.model.MedicalRecAi;
import lombok.Data;
import java.util.List;
/**
* @Authorlongbao
* @Date2024/11/14 11:18
* @Description:
*/
@Data
public class MedicalPromptStatsResVo {
// 模板名称
private List<MedicalRecAi> medicalRecAisCommon;
// 其他属性
private List<MedicalRecAi> medicalRecAisPara;
}

@ -0,0 +1,6 @@
package com.supervision.manage.service;
public interface AiMangeService {
String talk(String question, String medicalRecord);
}

@ -2,6 +2,7 @@ package com.supervision.manage.service;
import com.supervision.model.Human; import com.supervision.model.Human;
import com.supervision.vo.manage.HumanReqVo; import com.supervision.vo.manage.HumanReqVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
@ -24,10 +25,28 @@ public interface HumanManageService {
boolean createHuman(HumanReqVo humanReqVo); boolean createHuman(HumanReqVo humanReqVo);
/**
*
* @param imageFile
* @param medicalId
* @return
*/
boolean createHuman(MultipartFile imageFile, String medicalId); boolean createHuman(MultipartFile imageFile, String medicalId);
boolean updateHuman(HumanReqVo human); boolean updateHuman(HumanReqVo human);
boolean deleteHuman(String id); boolean deleteHuman(String id);
/**
* +=
* @param imageFile
* @param videoFile
* @param answer
* @param response
* @return
*/
boolean createHumanAnswerVideo(MultipartFile imageFile, MultipartFile videoFile, String answer, HttpServletResponse response);
} }

@ -0,0 +1,34 @@
package com.supervision.manage.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.model.MedicalRecAi;
import com.supervision.vo.manage.MedicalRecAiManageCreateVO;
import com.supervision.vo.manage.MedicalRecAiManageReqVO;
import com.supervision.vo.manage.MedicalRecAiManageUpdateVO;
import com.supervision.vo.manage.MedicalRecPageResVO;
import java.util.List;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
public interface MedicalManageAiDicService {
void delete(String id);
void modify(MedicalRecAiManageUpdateVO reqVO);
void create(MedicalRecAiManageCreateVO reqVO);
IPage<MedicalRecPageResVO> queryPage(String attributeName, Integer pageNum, Integer pageSize);
List<MedicalRecAi> queryAi();
List<MedicalRecAi> queryByCodeList(String codeList);
MedicalRecAi queryByCode();
}

@ -1,9 +1,10 @@
package com.supervision.manage.service; package com.supervision.manage.service;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.manage.pojo.vo.*; import com.supervision.manage.pojo.vo.*;
import com.supervision.model.Disease; import com.supervision.model.Disease;
import com.supervision.model.MedicalRec; import com.supervision.model.MedicalRecAi;
import com.supervision.vo.manage.*; import com.supervision.vo.manage.*;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -66,11 +67,15 @@ public interface MedicalRecManageService {
/** /**
* *
* * @return
* @param medicalRecId
* @param medicalRecAi
*/ */
void uploadMedicalAi(String medicalRecId, String medicalRecAi); MedicalPromptStatsResVo queryMedicalPromptStats();
/**
*
* @param medicalRecAi
*/
void uploadMedicalAi(MedicalRecCreateAiManageVO medicalRecAi);
} }

@ -0,0 +1,60 @@
package com.supervision.manage.service.impl;
import cn.hutool.core.util.StrUtil;
import com.supervision.manage.pojo.ai.AiMangeTalkAnswerDTO;
import com.supervision.manage.service.AiMangeService;
import com.supervision.util.AiChatUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.SystemMessage;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.stereotype.Service;
import java.util.*;
@Slf4j
@Service
public class AiServiceImpl implements AiMangeService {
public static final String userPromptTemplate = """
---
{medicalRecord}
---
json:{"answer":"你是一个总结提取专家,根据详细情况,进行归纳总结提取"}
""";
private static final String systemPrompt = """
,,
,,,!
""";
/**
*
*
* @param question
* @return
*/
public String talk(String question, String medicalRecord) {
Map<String, String> paramMap = new HashMap<>();
paramMap.put("medicalRecord", medicalRecord);
List<Message> messageHistoryList = new ArrayList<>();
messageHistoryList.add(new SystemMessage(systemPrompt));
messageHistoryList.add(new UserMessage(StrUtil.format(userPromptTemplate, paramMap)));
messageHistoryList.add(new AssistantMessage("好的,已了解我要扮演病人的详细情况。已准备好对话了。"));
messageHistoryList.add(new UserMessage(question));
Optional<AiMangeTalkAnswerDTO> chat = AiChatUtil.chat(messageHistoryList, AiMangeTalkAnswerDTO.class);
if (chat.isPresent()) {
AiMangeTalkAnswerDTO aiTalkAnswerDTO = chat.get();
if (StrUtil.isNotBlank(aiTalkAnswerDTO.getAnswer())) {
return aiTalkAnswerDTO.getAnswer();
}
}
return "医生,我没有听懂你说的是什么";
}
}

@ -22,6 +22,7 @@ import com.supervision.service.MedicalRecService;
import com.supervision.util.OkHttpUtils; import com.supervision.util.OkHttpUtils;
import com.supervision.util.UserUtil; import com.supervision.util.UserUtil;
import com.supervision.vo.manage.HumanReqVo; import com.supervision.vo.manage.HumanReqVo;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -289,6 +290,10 @@ public class HumanManageServiceImpl implements HumanManageService {
.one(); .one();
Assert.isTrue(null != medicalRec, "请先导入病例后再操作"); Assert.isTrue(null != medicalRec, "请先导入病例后再操作");
String name = imageFile.getName();
// 限制文件名称必须大于等于三个字符
Assert.isTrue(name.length() > 3, "请先导入病例后再操作");
// 上传图片 // 上传图片
FileResource fileResource = fileManageService.uploadFile(imageFile, imageFile.getContentType()); FileResource fileResource = fileManageService.uploadFile(imageFile, imageFile.getContentType());
@ -321,4 +326,28 @@ public class HumanManageServiceImpl implements HumanManageService {
}); });
return true; return true;
} }
/**
* +=
*
* @param imageFile
* @param videoFile
* @param answer
* @param response
* @return
*/
@Override
public boolean createHumanAnswerVideo(MultipartFile imageFile,
MultipartFile videoFile,
String answer,
HttpServletResponse response) {
// 1. 生成特色语音内容
// 2. 根据语音生成视频
// 3. 返回视频下载
return false;
}
} }

@ -0,0 +1,69 @@
package com.supervision.manage.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.manage.service.MedicalManageAiDicService;
import com.supervision.model.MedicalRecAi;
import com.supervision.service.MedicalAiDicService;
import com.supervision.vo.manage.MedicalRecAiManageCreateVO;
import com.supervision.vo.manage.MedicalRecAiManageReqVO;
import com.supervision.vo.manage.MedicalRecAiManageUpdateVO;
import com.supervision.vo.manage.MedicalRecPageResVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class MedicalManageAiDicServiceImpl implements MedicalManageAiDicService {
@Autowired
private MedicalAiDicService medicalAiDicService;
@Override
public void delete(String id) {
medicalAiDicService.delete(id);
}
@Override
public void modify(MedicalRecAiManageUpdateVO reqVO) {
medicalAiDicService.modify(reqVO);
}
@Override
public void create(MedicalRecAiManageCreateVO reqVO) {
medicalAiDicService.create(reqVO);
}
@Override
public IPage<MedicalRecPageResVO> queryPage(String attributeName, Integer pageNum, Integer pageSize) {
return medicalAiDicService.queryPage(attributeName, pageNum, pageSize);
}
@Override
public List<MedicalRecAi> queryAi() {
return medicalAiDicService.queryAi();
}
@Override
public List<MedicalRecAi> queryByCodeList(String codeList) {
return medicalAiDicService.queryByCodeList(codeList);
}
@Override
public MedicalRecAi queryByCode() {
return medicalAiDicService.queryByCode();
}
}

@ -10,8 +10,11 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.dto.*; import com.supervision.dto.*;
import com.supervision.enums.MedicalCommonTemplateEnum;
import com.supervision.exception.BusinessException; import com.supervision.exception.BusinessException;
import com.supervision.manage.pojo.vo.*; import com.supervision.manage.pojo.vo.*;
import com.supervision.manage.service.*; import com.supervision.manage.service.*;
@ -21,6 +24,7 @@ import com.supervision.model.*;
import com.supervision.model.Process; import com.supervision.model.Process;
import com.supervision.service.*; import com.supervision.service.*;
import com.supervision.service.MedicalRecService; import com.supervision.service.MedicalRecService;
import com.supervision.util.AiChatUtil;
import com.supervision.util.UserUtil; import com.supervision.util.UserUtil;
import com.supervision.vo.manage.*; import com.supervision.vo.manage.*;
import jakarta.servlet.ServletOutputStream; import jakarta.servlet.ServletOutputStream;
@ -29,6 +33,11 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.SystemMessage;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.vectorstore.RedisVectorStore;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -48,6 +57,14 @@ import java.util.stream.Collectors;
public class MedicalRecManageServiceImpl implements MedicalRecManageService { public class MedicalRecManageServiceImpl implements MedicalRecManageService {
private static final String systemPrompt = """
,
,,
,,,!
'',','!!!
""";
private final String CASE_TEMPLATE_TEMPLATE_EXCEL_PATH = "classpath:template/虚拟病例信息模板v3.0.xlsx"; private final String CASE_TEMPLATE_TEMPLATE_EXCEL_PATH = "classpath:template/虚拟病例信息模板v3.0.xlsx";
private final String MEDICAL_ANSWER_TEMPLATE_EXCEL_PATH = "classpath:template/medical_answer_template.xlsx"; private final String MEDICAL_ANSWER_TEMPLATE_EXCEL_PATH = "classpath:template/medical_answer_template.xlsx";
@ -78,10 +95,12 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
private final AnswerVideoResourceService answerVideoResourceService; private final AnswerVideoResourceService answerVideoResourceService;
private final MaterialLibraryService materialLibraryService;
private final ProcessService processService; private final ProcessService processService;
private final MedicalManageAiDicService medicalManageAiDicService;
private final AiMangeService aiService;
public List<Disease> queryDiseaseListByDropList() { public List<Disease> queryDiseaseListByDropList() {
return diseaseService.lambdaQuery().list(); return diseaseService.lambdaQuery().list();
} }
@ -112,6 +131,7 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
// 然后保存病历 // 然后保存病历
MedicalRec medicalRec = BeanUtil.toBean(reqVO, MedicalRec.class); MedicalRec medicalRec = BeanUtil.toBean(reqVO, MedicalRec.class);
medicalRec.setDiseaseId(reqVO.getDiseaseId()); medicalRec.setDiseaseId(reqVO.getDiseaseId());
medicalRec.setAi();
medicalRec.insert(); medicalRec.insert();
// 这里生成一个新的编号(首先去数据库里面查询编号,然后用最大的编号+1)(可能存在并发修改导致编码重复问题,不是重点,等有问题再说) // 这里生成一个新的编号(首先去数据库里面查询编号,然后用最大的编号+1)(可能存在并发修改导致编码重复问题,不是重点,等有问题再说)
medicalRecService.updateMedicalRecNo("QL", "男".equals(reqVO.getPatientGender()) ? "M" : "F", medicalRec.getId()); medicalRecService.updateMedicalRecNo("QL", "男".equals(reqVO.getPatientGender()) ? "M" : "F", medicalRec.getId());
@ -570,7 +590,7 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
medicalRec.setMedicalStatus(MedicalStatusEnum.CREATE.getCode()); medicalRec.setMedicalStatus(MedicalStatusEnum.CREATE.getCode());
medicalRec.setMedicalImportType(MedicalTypeEnum.TEMPLATE_IMPORT.getCode()); medicalRec.setMedicalImportType(MedicalTypeEnum.TEMPLATE_IMPORT.getCode());
medicalRec.setMedicalRecordAi("姓名:" + name + "\n性别" + sex + "\n年龄" + ageStar medicalRec.setMedicalRecordAi("姓名:" + name + "\n性别" + sex + "\n年龄" + ageStar
+ "\n婚育史" + maritalStatus + "\n职业" + occupation + "\n家庭住址" + address + "\n病史叙述者本人"); + "\n婚育史" + maritalStatus + "\n职业" + occupation + "\n家庭住址" + address + "\n病史叙述者本人\n");
medicalRecService.save(medicalRec); medicalRecService.save(medicalRec);
medicalRecService.updateMedicalRecNo("QL", "男".equals(sex) ? "M" : "F", medicalRec.getId()); medicalRecService.updateMedicalRecNo("QL", "男".equals(sex) ? "M" : "F", medicalRec.getId());
return medicalRec; return medicalRec;
@ -737,16 +757,56 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
/** /**
* *
* *
* @param medicalRecId * @return
* @param medicalRecAi
*/ */
@Override @Override
public void uploadMedicalAi(String medicalRecId, String medicalRecAi) { public MedicalPromptStatsResVo queryMedicalPromptStats() {
MedicalPromptStatsResVo medicalPromptStatsResVo = new MedicalPromptStatsResVo();
List<MedicalRecAi> medicalRecAisCommon = medicalManageAiDicService.queryByCodeList(MedicalCommonTemplateEnum.COMMON_TEMPLATE_ENUM.getCode());
List<MedicalRecAi> medicalRecAisPara = medicalManageAiDicService.queryByCodeList(MedicalCommonTemplateEnum.PARA_TEMPLATE_ENUM.getCode());
medicalPromptStatsResVo.setMedicalRecAisCommon(medicalRecAisCommon);
medicalPromptStatsResVo.setMedicalRecAisPara(medicalRecAisPara);
return medicalPromptStatsResVo;
}
@Override
public void uploadMedicalAi(MedicalRecCreateAiManageVO medicalRecCreateAiManageVO) {
String medicalRecId = medicalRecCreateAiManageVO.getMedicalRecId();
String ai = "";
String patientAnswerString = "";
// 通用模板属性
String commonModelParam = medicalRecCreateAiManageVO.getCommonModelParam();
List<AskPatientAnswer> askPatientAnswers = askPatientAnswerService.lambdaQuery()
.select(AskPatientAnswer::getQuestion, AskPatientAnswer::getAnswer)
.eq(AskPatientAnswer::getMedicalId, medicalRecId)
.list();
for (AskPatientAnswer askPatientAnswer : askPatientAnswers) {
if (null != askPatientAnswer){
patientAnswerString = patientAnswerString + askPatientAnswer.getQuestion() + "," + askPatientAnswer.getAnswer() + ",";
}
}
// 其他属性集合
List<MedicalRecCreateListAiManageVO> medicalRecCreateListAiManageVOS = medicalRecCreateAiManageVO.getMedicalRecCreateListAiManageVOS();
for (MedicalRecCreateListAiManageVO medicalRecCreateListAiManageVO : medicalRecCreateListAiManageVOS) {
String attributeName = medicalRecCreateListAiManageVO.getAttributeName();
String attributeParam = medicalRecCreateListAiManageVO.getAttributeParam();
String answer = aiService.talk(attributeParam, patientAnswerString);
ai = attributeName + "" + answer + "\n";
}
MedicalRec byId = medicalRecService.getById(medicalRecId);
String medicalRecordAi = byId.getMedicalRecordAi();
MedicalRec medicalRec = new MedicalRec(); MedicalRec medicalRec = new MedicalRec();
medicalRec.setId(medicalRecId); medicalRec.setId(medicalRecId);
medicalRec.setMedicalRecordAi(medicalRecAi); medicalRec.setMedicalRecordAi(medicalRecordAi + ai);
this.medicalRecService.updateById(medicalRec); medicalRecService.updateById(medicalRec);
} }
} }

@ -0,0 +1,26 @@
package com.supervision.enums;
import lombok.Getter;
/**
* @Authorlongbao
* @Date2024/11/13 16:44
* @Description:
*/
@Getter
public enum MedicalCommonTemplateEnum {
COMMON_TEMPLATE_ENUM("00", "病历提示词模板-通用模板"),
PARA_TEMPLATE_ENUM("01", "病历提示词模板-属性模板"),
;
private String description;
private String code;
MedicalCommonTemplateEnum(String code, String description) {
this.description = description;
this.code = code;
}
}

@ -0,0 +1,22 @@
package com.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.supervision.model.MedicalRecAi;
import com.supervision.vo.manage.MedicalRecAiManageReqVO;
import com.supervision.vo.manage.MedicalRecPageResVO;
import org.apache.ibatis.annotations.Param;
/**
* @Authorlongbao
* @Date2024/11/14 9:51
* @Description: vp_medical_ai_dic
*/
public interface MedicalAiMapper extends BaseMapper<MedicalRecAi> {
IPage<MedicalRecPageResVO> queryPage(@Param("medicalRecAiManageVO") MedicalRecAiManageReqVO medicalRecAiManageVO,
@Param("page") Page<MedicalRecPageResVO> page);
}

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -19,163 +20,149 @@ import java.time.LocalDateTime;
@TableName(value = "vp_medical_rec", autoResultMap = true) @TableName(value = "vp_medical_rec", autoResultMap = true)
@Data @Data
public class MedicalRec extends Model<MedicalRec> implements Serializable { public class MedicalRec extends Model<MedicalRec> implements Serializable {
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
@TableId @TableId
private String id; private String id;
/** /**
* *
*/ */
private String no; private String no;
@Schema(description = "数字人id") @Schema(description = "数字人id")
private String humanId; private String humanId;
/** /**
* *
*/ */
private String patientHeadPic; private String patientHeadPic;
/** /**
* 0:线 1:线 * 0:线 1:线
*/ */
private int digitalHumanType; private int digitalHumanType;
/** /**
* *
*/ */
private String patientName; private String patientName;
/** /**
* / * /
*/ */
private String patientGender; private String patientGender;
/** /**
* *
*/ */
private Integer patientAge; private Integer patientAge;
/** /**
* 0: 1: * 0: 1:
*/ */
private String patientMarriage; private String patientMarriage;
/** /**
* *
*/ */
private String patientProfession; private String patientProfession;
/** /**
* *
*/ */
private String patientPhone; private String patientPhone;
/** /**
* *
*/ */
private String nativePlace; private String nativePlace;
/** /**
* *
*/ */
private String patientNation; private String patientNation;
/** /**
* *
*/ */
private String patientPostcode; private String patientPostcode;
/** /**
* *
*/ */
private String patientBirthplace; private String patientBirthplace;
/** /**
* *
*/ */
private String patientHabitation; private String patientHabitation;
/** /**
* ID * ID
*/ */
@Deprecated @Deprecated
private String patientId; private String patientId;
/** /**
* id * id
*/ */
private String diseaseId; private String diseaseId;
/** /**
* *
*/ */
private String patientSelfDesc; private String patientSelfDesc;
/** /**
* *
*/ */
private String symptoms; private String symptoms;
@Schema(description = "初步诊断依据") @Schema(description = "初步诊断依据")
private String primarilyDiagnosisCriteria; private String primarilyDiagnosisCriteria;
@Schema(description = "证实诊断依据") @Schema(description = "证实诊断依据")
private String confirmDiagnosisCriteria; private String confirmDiagnosisCriteria;
@Schema(description = "鉴别诊断依据") @Schema(description = "鉴别诊断依据")
private String differentialDiagnosisCriteria; private String differentialDiagnosisCriteria;
// 2024.11.05:与周霞沟通后修改全面检查字段为 *预期诊断结果 // 2024.11.05:与周霞沟通后修改全面检查字段为 *预期诊断结果
@Schema(description = "预期诊断结果") @Schema(description = "预期诊断结果")
private String fullCheck; private String fullCheck;
@Schema(description = "提交给大模型的病历") @Schema(description = "提交给大模型的病历")
private String medicalRecordAi; private String medicalRecordAi;
@Schema(description = "上线状态 1未上线 2已经上线 状态为未上线且病历未出现在vp_process表中使用可以进行删除") @Schema(description = "上线状态 1未上线 2已经上线 状态为未上线且病历未出现在vp_process表中使用可以进行删除")
private Integer status; private Integer status;
/** /**
* ID * ID
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private String createUserId; private String createUserId;
/** /**
* *
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
/** /**
* *
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUserId; private String updateUserId;
/** /**
* *
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime; private LocalDateTime updateTime;
/** /**
* *
*/ */
@Schema(description = "病例生成状态") @Schema(description = "病例生成状态")
private String medicalStatus; private String medicalStatus;
/** /**
* *
*/ */
@Schema(description = "病例创建类型") @Schema(description = "病例创建类型")
private String medicalImportType; private String medicalImportType;
// 设置ai值
@TableField(exist = false) public void setAi() {
private static final long serialVersionUID = 1L; if (StringUtils.isNotEmpty(this.getPatientName())) {
this.setMedicalRecordAi("姓名:" + this.getPatientName() + "\n");
}
if (StringUtils.isNotEmpty(this.getPatientGender())) {
this.setMedicalRecordAi("性别:" + this.getPatientName() + "\n");
}
if (StringUtils.isNotEmpty(String.valueOf(this.getPatientAge()))) {
this.setMedicalRecordAi("年龄:" + String.valueOf(this.getPatientAge()) + "\n");
}
if (StringUtils.isNotEmpty(this.getPatientMarriage())) {
this.setMedicalRecordAi("婚育史:" + this.getPatientMarriage() + "\n");
}
if (StringUtils.isNotEmpty(this.getPatientHabitation())) {
this.setMedicalRecordAi("家庭住址:" + this.getPatientHabitation() + "\n");
}
this.setMedicalRecordAi(this.getMedicalRecordAi() + "\n病史叙述者本人");
}
} }

@ -0,0 +1,53 @@
package com.supervision.model;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @Authorlongbao
* @Date2024/11/14 9:40
* @Description: vp_medical_ai_dic
*/
@TableName(value = "vp_medical_ai_dic", autoResultMap = true)
@Data
public class MedicalRecAi extends Model<MedicalRecAi> implements Serializable {
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(type = IdType.AUTO)
private Long id;
private String attributeName;
private String attributeParam;
private String commonName;
private String commonType;
private String createUserId;
private String updateUserId;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime createTime;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}

@ -0,0 +1,32 @@
package com.supervision.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.model.MedicalRecAi;
import com.supervision.vo.manage.MedicalRecAiManageCreateVO;
import com.supervision.vo.manage.MedicalRecAiManageReqVO;
import com.supervision.vo.manage.MedicalRecAiManageUpdateVO;
import com.supervision.vo.manage.MedicalRecPageResVO;
import java.util.List;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
public interface MedicalAiDicService {
void delete(String id);
void modify(MedicalRecAiManageUpdateVO reqVO);
void create(MedicalRecAiManageCreateVO reqVO);
IPage<MedicalRecPageResVO> queryPage(String attributeName, Integer pageNum, Integer pageSize);
List<MedicalRecAi> queryAi();
List<MedicalRecAi> queryByCodeList(String codeList);
MedicalRecAi queryByCode();
}

@ -0,0 +1,93 @@
package com.supervision.service.impl;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.enums.MedicalCommonTemplateEnum;
import com.supervision.mapper.MedicalAiMapper;
import com.supervision.model.CommonDic;
import com.supervision.model.MedicalRecAi;
import com.supervision.service.CommonDicService;
import com.supervision.service.MedicalAiDicService;
import com.supervision.util.UserUtil;
import com.supervision.vo.manage.MedicalRecAiManageCreateVO;
import com.supervision.vo.manage.MedicalRecAiManageReqVO;
import com.supervision.vo.manage.MedicalRecAiManageUpdateVO;
import com.supervision.vo.manage.MedicalRecPageResVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class MedicalAiDicServiceImpl extends ServiceImpl<MedicalAiMapper, MedicalRecAi> implements MedicalAiDicService {
@Autowired
private CommonDicService commonDicService;
@Override
public void delete(String id) {
this.removeById(id);
}
@Override
public void modify(MedicalRecAiManageUpdateVO reqVO) {
MedicalRecAi medicalRecAi = new MedicalRecAi();
medicalRecAi.setId(reqVO.getId());
medicalRecAi.setAttributeName(reqVO.getAttributeName());
medicalRecAi.setAttributeParam(reqVO.getAttributeParam());
medicalRecAi.setCommonType(reqVO.getCommonType());
medicalRecAi.setCommonName(reqVO.getCommonName());
medicalRecAi.setUpdateUserId(UserUtil.getUser().getUpdateUserId());
this.updateById(medicalRecAi);
}
@Override
public void create(MedicalRecAiManageCreateVO reqVO) {
MedicalRecAi medicalRecAi = new MedicalRecAi();
medicalRecAi.setAttributeName(reqVO.getAttributeName());
medicalRecAi.setAttributeParam(reqVO.getAttributeParam());
medicalRecAi.setCommonName(reqVO.getCommonName());
medicalRecAi.setCommonType(reqVO.getCommonType());
medicalRecAi.setCreateUserId(UserUtil.getUser().getCreateUserId());
medicalRecAi.setUpdateUserId(UserUtil.getUser().getUpdateUserId());
this.save(medicalRecAi);
}
@Override
public IPage<MedicalRecPageResVO> queryPage(String attributeName, Integer pageNum, Integer pageSize) {
MedicalRecAiManageReqVO medicalRecPageReqVO = new MedicalRecAiManageReqVO();
medicalRecPageReqVO.setAttributeName(attributeName);
return this.baseMapper.queryPage(medicalRecPageReqVO, new Page<>(pageNum, pageSize));
}
@Override
public List<MedicalRecAi> queryAi() {
return this.lambdaQuery().list();
}
@Override
public List<MedicalRecAi> queryByCodeList(String code) {
return this.lambdaQuery().eq(MedicalRecAi::getCommonType, code).list();
}
@Override
public MedicalRecAi queryByCode() {
return this.lambdaQuery().eq(MedicalRecAi::getCommonType, MedicalCommonTemplateEnum.COMMON_TEMPLATE_ENUM.getCode()).one();
}
}

@ -0,0 +1,26 @@
package com.supervision.vo.manage;
import com.supervision.model.MedicalRecAi;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
@Data
public class MedicalRecAiManageCreateVO {
@Schema(description = "模板类型")
private String commonType;
@Schema(description = "模板名称")
private String commonName;
@Schema(description = "属性名称")
private String attributeName;
@Schema(description = "提示词")
private String attributeParam;
}

@ -0,0 +1,18 @@
package com.supervision.vo.manage;
import com.supervision.model.MedicalRecAi;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
@Data
@Schema(description = "病历管理创建及新建", implementation = MedicalRecAi.class)
public class MedicalRecAiManageReqVO {
@Schema(description = "属性名称")
private String attributeName;
}

@ -0,0 +1,29 @@
package com.supervision.vo.manage;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
@Data
public class MedicalRecAiManageUpdateVO {
@Schema(description = "id")
private Long id;
@Schema(description = "属性名称")
private String attributeName;
@Schema(description = "提示词")
private String attributeParam;
@Schema(description = "模板名称")
private String commonName;
@Schema(description = "模板类型")
private String commonType;
}

@ -0,0 +1,37 @@
package com.supervision.vo.manage;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @Authorlongbao
* @Date2024/11/14 9:51
* @Description:
*/
@Data
public class MedicalRecAiPageResVO {
private String id;
private String commonType;
private String commonName;
private String attributeName;
private String attributeParam;
private String createUserId;
private String updateUserId;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}

@ -0,0 +1,25 @@
package com.supervision.vo.manage;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description:
*/
@Data
public class MedicalRecCreateAiManageVO {
@Schema(description = "病例id")
private String medicalRecId;
@Schema(description = "通用模板属性")
private String commonModelParam;
@Schema(description = "属性")
private List<MedicalRecCreateListAiManageVO> medicalRecCreateListAiManageVOS;
}

@ -0,0 +1,23 @@
package com.supervision.vo.manage;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @Authorlongbao
* @Date2024/11/14 9:32
* @Description: -
*/
@Data
public class MedicalRecCreateListAiManageVO {
@Schema(description = "属性提示词")
private String attributeParam;
@Schema(description = "属性名称")
private String attributeName;
}

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.MedicalAiMapper">
<resultMap id="BaseResultMap" type="com.supervision.model.MedicalRecAi">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="commonName" column="attribute_value" jdbcType="VARCHAR"/>
<result property="commonType" column="attribute_code" jdbcType="VARCHAR"/>
<result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
<result property="attributeParam" column="attribute_param" jdbcType="INTEGER"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="BaseResultResMap" type="com.supervision.vo.manage.MedicalRecAiPageResVO">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="commonType" column="common_type" jdbcType="VARCHAR"/>
<result property="commonName" column="common_name" jdbcType="VARCHAR"/>
<result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
<result property="attributeParam" column="attribute_param" jdbcType="INTEGER"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
,medical_id,library_question_id,code,question,
answer,answer_resources_id,answer_type,create_user_id,
create_time,update_user_id,update_time
</sql>
<select id="queryPage" resultMap="BaseResultResMap">
select ai.id,
ai.attribute_name ,
ai.attribute_param ,
ai.create_user_id ,
ai.create_time ,
ai.update_user_id ,
ai.update_time ,
ai.common_type ,
ai.common_name
from vp_medical_ai_dic ai
<where>
<if test="medicalRecAiManageVO.attributeName != null and medicalRecAiManageVO.attributeName != ''">
and ai.attribute_name like concat('%',#{medicalRecAiManageVO.attributeName}, ''%'')
</if>
</where>
order by ai.create_time desc
</select>
</mapper>
Loading…
Cancel
Save