太湖云医医案收集
This commit is contained in:
@@ -0,0 +1,115 @@
|
|||||||
|
package com.peanut.modules.common.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.common.utils.ShiroUtils;
|
||||||
|
import com.peanut.modules.common.entity.MedicalRecords;
|
||||||
|
import com.peanut.modules.common.entity.MedicalRecordsToLabel;
|
||||||
|
import com.peanut.modules.common.service.MedicalRecordsService;
|
||||||
|
import com.peanut.modules.common.service.MedicalRecordsToLabelService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.ai.chat.client.ChatClient;
|
||||||
|
import org.springframework.ai.tool.ToolCallbackProvider;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController("commonMedicalRecords")
|
||||||
|
@RequestMapping("common/medicalRecords")
|
||||||
|
public class MedicalRecordsController {
|
||||||
|
|
||||||
|
private final ChatClient chatClient;
|
||||||
|
@Autowired
|
||||||
|
private MedicalRecordsService medicalRecordsService;
|
||||||
|
@Autowired
|
||||||
|
private MedicalRecordsToLabelService medicalRecordsToLabelService;
|
||||||
|
|
||||||
|
public MedicalRecordsController(ChatClient.Builder chatClientBuilder, ToolCallbackProvider tools) {
|
||||||
|
this.chatClient = chatClientBuilder.defaultToolCallbacks(tools).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
//拆分医案段落
|
||||||
|
@RequestMapping(value = "/medicalRecordsSplit")
|
||||||
|
public R medicalRecordsSplit(@RequestBody Map<String,Object> parmas) {
|
||||||
|
MedicalRecords mr = new MedicalRecords();
|
||||||
|
String uuid = UUID.randomUUID().toString();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
Date date = new Date();
|
||||||
|
chatClient.prompt()
|
||||||
|
.user("你是一名文档编辑,给你一份资料,必须按照1.一般信息,2.主诉,3.现病史,4.既往史,5.家族史,6.体格检查,7.诊断,8.治疗和后续治疗;" +
|
||||||
|
"这8方面进行拆分,不要增删内容,个人信息必须脱敏处理,结果必须是markdown格式;内容如下:"+
|
||||||
|
parmas.get("message").toString())
|
||||||
|
.stream()
|
||||||
|
.content()
|
||||||
|
.doOnNext(data -> {
|
||||||
|
sb.append(data);
|
||||||
|
})
|
||||||
|
.doFinally(data -> {
|
||||||
|
System.out.println(sb);
|
||||||
|
String res = sb.toString().replace("```markdown\n","").replace("```","");
|
||||||
|
String[] datas = res.split("\n\n");
|
||||||
|
mr.setUserId(ShiroUtils.getUId());
|
||||||
|
mr.setInformation(datas[0]);
|
||||||
|
mr.setChiefComplaint(datas[1]);
|
||||||
|
mr.setHistoryOfPresentIllness(datas[2]);
|
||||||
|
mr.setPastHistory(datas[3]);
|
||||||
|
mr.setPersonalAndFamilyHistory(datas[4]);
|
||||||
|
mr.setPhysicaExamination(datas[5]);
|
||||||
|
mr.setDiagnosis(datas[6]);
|
||||||
|
mr.setTreatmentPlan(datas[7]);
|
||||||
|
mr.setData(uuid+"->\n"+res);
|
||||||
|
medicalRecordsService.save(mr);
|
||||||
|
System.out.println(new Date().getTime()-date.getTime());
|
||||||
|
})
|
||||||
|
.subscribe();
|
||||||
|
return R.ok().put("data",uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询正在拆分的医案
|
||||||
|
@RequestMapping(value = "/medicalRecordsQuerySplit")
|
||||||
|
public R medicalRecordsQuerySplit(@RequestBody Map<String,Object> parmas) {
|
||||||
|
List<MedicalRecords> list = medicalRecordsService.list(new LambdaQueryWrapper<MedicalRecords>()
|
||||||
|
.like(MedicalRecords::getData,parmas.get("queryFlag")));
|
||||||
|
return R.ok().put("medicalRecords",list.size()>0?list.get(0):null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//暂存或者保存医案
|
||||||
|
@RequestMapping(value = "/saveMedicalRecords")
|
||||||
|
@Transactional
|
||||||
|
public R saveMedicalRecords(@RequestBody MedicalRecords medicalRecords) {
|
||||||
|
MedicalRecordsToLabel toLabel = new MedicalRecordsToLabel();
|
||||||
|
toLabel.setRecordId(medicalRecords.getId());
|
||||||
|
toLabel.setLabelId(medicalRecords.getLabelId());
|
||||||
|
medicalRecordsToLabelService.save(toLabel);
|
||||||
|
if (medicalRecords.getState()==1){
|
||||||
|
if ("儿科".equals(medicalRecords.getLabelTitle())){
|
||||||
|
if ((!medicalRecords.getPastHistory().contains("接种")&&
|
||||||
|
!medicalRecords.getPastHistory().contains("疫苗"))&&
|
||||||
|
(!medicalRecords.getPersonalAndFamilyHistory().contains("接种")&&
|
||||||
|
!medicalRecords.getPersonalAndFamilyHistory().contains("疫苗"))){
|
||||||
|
return R.error("请补充患者疫苗接种信息");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("妇科".equals(medicalRecords.getLabelTitle())){
|
||||||
|
if ((!medicalRecords.getPastHistory().contains("月经")&&
|
||||||
|
!medicalRecords.getPastHistory().contains("例假")&&
|
||||||
|
!medicalRecords.getPastHistory().contains("婚育"))&&
|
||||||
|
(!medicalRecords.getPersonalAndFamilyHistory().contains("月经")&&
|
||||||
|
!medicalRecords.getPersonalAndFamilyHistory().contains("例假")&&
|
||||||
|
!medicalRecords.getPersonalAndFamilyHistory().contains("婚育"))){
|
||||||
|
return R.error("请补充患者月经婚育信息");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
medicalRecordsService.save(medicalRecords);
|
||||||
|
return R.ok().put("medicalRecords",medicalRecords);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.peanut.modules.common.entity;
|
package com.peanut.modules.common.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
@@ -48,5 +49,9 @@ public class MedicalRecords {
|
|||||||
@TableLogic
|
@TableLogic
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer labelId;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String labelTitle;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -30,6 +31,38 @@ public class MedicalRecordsController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MedicalRecordsToLabelService toLabelService;
|
private MedicalRecordsToLabelService toLabelService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/getMedicalRecordsList")
|
||||||
|
public R getMedicalRecordsList(@RequestBody Map<String,Object> params){
|
||||||
|
MPJLambdaWrapper<MedicalRecords> wrapper = new MPJLambdaWrapper();
|
||||||
|
wrapper.rightJoin(MedicalRecordsToLabel.class,MedicalRecordsToLabel::getRecordId,MedicalRecords::getId);
|
||||||
|
wrapper.selectAll(MedicalRecords.class);
|
||||||
|
wrapper.eq(MedicalRecordsToLabel::getLabelId,params.get("labelId"));
|
||||||
|
wrapper.eq(MedicalRecords::getState,1);
|
||||||
|
wrapper.eq(StringUtils.isNotBlank(params.get("train").toString()),MedicalRecords::getTrain,params.get("train"));
|
||||||
|
wrapper.eq(StringUtils.isNotBlank(params.get("title").toString()),MedicalRecords::getTitle,params.get("title"));
|
||||||
|
Page<MedicalRecords> page = medicalRecordsService.page(new Page<>(
|
||||||
|
Long.parseLong(params.get("current").toString()),Long.parseLong(params.get("limit").toString())),wrapper);
|
||||||
|
return R.ok().put("page",page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/addMedicalRecords")
|
||||||
|
public R addMedicalRecords(@RequestBody MedicalRecords medicalRecords){
|
||||||
|
medicalRecords.setState(1);
|
||||||
|
medicalRecordsService.updateById(medicalRecords);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/editMedicalRecords")
|
||||||
|
public R editMedicalRecords(@RequestBody MedicalRecords medicalRecords){
|
||||||
|
medicalRecordsService.updateById(medicalRecords);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/getMedicalRecordsLabelList")
|
@RequestMapping("/getMedicalRecordsLabelList")
|
||||||
public R getMedicalRecordsLabelList(){
|
public R getMedicalRecordsLabelList(){
|
||||||
return R.ok().put("Medicals", medicalRecordsLabels(0));
|
return R.ok().put("Medicals", medicalRecordsLabels(0));
|
||||||
|
|||||||
Reference in New Issue
Block a user