医案收集
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
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.MedicalRecordsLabel;
|
||||
import com.peanut.modules.common.entity.MedicalRecordsToLabel;
|
||||
import com.peanut.modules.common.service.MedicalRecordsLabelService;
|
||||
import com.peanut.modules.common.service.MedicalRecordsService;
|
||||
import com.peanut.modules.common.service.MedicalRecordsToLabelService;
|
||||
import com.vladsch.flexmark.html.HtmlRenderer;
|
||||
import com.vladsch.flexmark.parser.Parser;
|
||||
import com.vladsch.flexmark.util.data.MutableDataSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.tool.ToolCallbackProvider;
|
||||
@@ -29,8 +35,27 @@ public class MedicalRecordsController {
|
||||
@Autowired
|
||||
private MedicalRecordsService medicalRecordsService;
|
||||
@Autowired
|
||||
private MedicalRecordsLabelService medicalRecordsLabelService;
|
||||
@Autowired
|
||||
private MedicalRecordsToLabelService medicalRecordsToLabelService;
|
||||
|
||||
//获取医案标签列表
|
||||
@RequestMapping("/getMedicalRecordsLabelList")
|
||||
public R getMedicalRecordsLabelList(){
|
||||
return R.ok().put("Medicals", medicalRecordsLabels(0));
|
||||
}
|
||||
private List<MedicalRecordsLabel> medicalRecordsLabels(int id){
|
||||
List<MedicalRecordsLabel> medicalRecordsLabelList = medicalRecordsLabelService.list(new LambdaQueryWrapper<MedicalRecordsLabel>()
|
||||
.eq(MedicalRecordsLabel::getPid, id));
|
||||
for (MedicalRecordsLabel m : medicalRecordsLabelList){
|
||||
if(m.getIsLast()!=1){
|
||||
List<MedicalRecordsLabel> so = this.medicalRecordsLabels(m.getId());
|
||||
m.setChildren(so);
|
||||
}
|
||||
}
|
||||
return medicalRecordsLabelList;
|
||||
}
|
||||
|
||||
public MedicalRecordsController(ChatClient.Builder chatClientBuilder, ToolCallbackProvider tools) {
|
||||
this.chatClient = chatClientBuilder.defaultToolCallbacks(tools).build();
|
||||
}
|
||||
@@ -39,12 +64,17 @@ public class MedicalRecordsController {
|
||||
@RequestMapping(value = "/medicalRecordsSplit")
|
||||
public R medicalRecordsSplit(@RequestBody Map<String,Object> parmas) {
|
||||
MedicalRecords mr = new MedicalRecords();
|
||||
mr.setUserId(ShiroUtils.getUId());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
medicalRecordsService.save(mr);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Date date = new Date();
|
||||
MutableDataSet options = new MutableDataSet();
|
||||
Parser parser = Parser.builder(options).build();
|
||||
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
|
||||
chatClient.prompt()
|
||||
.user("你是一名文档编辑,给你一份资料,必须按照1.一般信息,2.主诉,3.现病史,4.既往史,5.家族史,6.体格检查,7.诊断,8.治疗和后续治疗;" +
|
||||
"这8方面进行拆分,不要增删内容,个人信息必须脱敏处理,结果必须是markdown格式;内容如下:"+
|
||||
.user("你是一名编辑,给你一份资料,必须按照1.一般信息,2.主诉,3.现病史,4.既往史,5.家族史,6.体格检查,7.诊断,8.治疗和后续治疗;" +
|
||||
"这8方面进行拆分,如果没有内容只显示标题,内容为无。内容开头必须为一般信息,不要增删内容,个人信息必须脱敏处理,结果必须是markdown格式;内容如下:"+
|
||||
parmas.get("message").toString())
|
||||
.stream()
|
||||
.content()
|
||||
@@ -55,28 +85,41 @@ public class MedicalRecordsController {
|
||||
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);
|
||||
mr.setInformation(renderer.render(parser.parse(datas[0])));
|
||||
mr.setChiefComplaint(renderer.render(parser.parse(datas[1])));
|
||||
mr.setHistoryOfPresentIllness(renderer.render(parser.parse(datas[2])));
|
||||
mr.setPastHistory(renderer.render(parser.parse(datas[3])));
|
||||
mr.setPersonalAndFamilyHistory(renderer.render(parser.parse(datas[4])));
|
||||
mr.setPhysicaExamination(renderer.render(parser.parse(datas[5])));
|
||||
mr.setDiagnosis(renderer.render(parser.parse(datas[6])));
|
||||
mr.setTreatmentPlan(renderer.render(parser.parse(datas[7])));
|
||||
mr.setData(uuid+"->");
|
||||
medicalRecordsService.saveOrUpdate(mr);
|
||||
System.out.println(new Date().getTime()-date.getTime());
|
||||
})
|
||||
.doOnError(error -> {
|
||||
medicalRecordsService.removeById(mr.getId());
|
||||
})
|
||||
.subscribe();
|
||||
return R.ok().put("data",uuid);
|
||||
return R.ok().put("data",mr.getId());
|
||||
}
|
||||
|
||||
//查询正在拆分的医案
|
||||
@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")));
|
||||
.eq(MedicalRecords::getId, parmas.get("id")));
|
||||
for (MedicalRecords mr : list){
|
||||
MedicalRecordsToLabel toLabel = medicalRecordsToLabelService.getOne(new LambdaQueryWrapper<MedicalRecordsToLabel>()
|
||||
.eq(MedicalRecordsToLabel::getRecordId,mr.getId()));
|
||||
if (toLabel!=null){
|
||||
mr.setLabelId(toLabel.getLabelId());
|
||||
MedicalRecordsLabel label = medicalRecordsLabelService.getById(toLabel.getLabelId());
|
||||
if (label!=null){
|
||||
mr.setLabelTitle(label.getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok().put("medicalRecords",list.size()>0?list.get(0):null);
|
||||
}
|
||||
|
||||
@@ -84,10 +127,6 @@ public class MedicalRecordsController {
|
||||
@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("接种")&&
|
||||
@@ -108,8 +147,37 @@ public class MedicalRecordsController {
|
||||
}
|
||||
}
|
||||
}
|
||||
medicalRecordsService.save(medicalRecords);
|
||||
medicalRecords.setData(medicalRecords.getInformation()+medicalRecords.getChiefComplaint()+medicalRecords.getHistoryOfPresentIllness()
|
||||
+medicalRecords.getPastHistory()+medicalRecords.getPastHistory()+medicalRecords.getPersonalAndFamilyHistory()
|
||||
+medicalRecords.getPhysicaExamination()+medicalRecords.getDiagnosis()+medicalRecords.getTreatmentPlan());
|
||||
medicalRecordsService.saveOrUpdate(medicalRecords);
|
||||
//绑定标签
|
||||
MedicalRecordsToLabel toLabel = medicalRecordsToLabelService.getOne(new LambdaQueryWrapper<MedicalRecordsToLabel>()
|
||||
.eq(MedicalRecordsToLabel::getLabelId, medicalRecords.getLabelId())
|
||||
.eq(MedicalRecordsToLabel::getRecordId,medicalRecords.getId()));
|
||||
if (toLabel==null){
|
||||
toLabel = new MedicalRecordsToLabel();
|
||||
}
|
||||
toLabel.setRecordId(medicalRecords.getId());
|
||||
toLabel.setLabelId(medicalRecords.getLabelId());
|
||||
medicalRecordsToLabelService.saveOrUpdate(toLabel);
|
||||
return R.ok().put("medicalRecords",medicalRecords);
|
||||
}
|
||||
|
||||
//删除医案
|
||||
@RequestMapping(value = "/delMmedicalRecords")
|
||||
public R delMmedicalRecords(@RequestBody Map<String,Object> parmas) {
|
||||
medicalRecordsService.removeById(parmas.get("id").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//医案列表
|
||||
@RequestMapping(value = "/medicalRecordsList")
|
||||
public R medicalRecordsList(@RequestBody Map<String,Object> parmas) {
|
||||
List<MedicalRecords> medicalRecordsList = medicalRecordsService.list(new LambdaQueryWrapper<MedicalRecords>()
|
||||
.eq(MedicalRecords::getUserId,ShiroUtils.getUId())
|
||||
.eq(MedicalRecords::getState,parmas.get("state")));
|
||||
return R.ok().put("medicalRecordsList",medicalRecordsList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ public class MedicalRecords {
|
||||
private Integer userId;
|
||||
//标题
|
||||
private String title;
|
||||
//0暂存1有效
|
||||
//0暂存1提交审核2审核拒绝3审核成功
|
||||
private Integer state;
|
||||
//是否加入ai训练库0否1是
|
||||
private Integer train;
|
||||
//未加入训练库原因
|
||||
private String trainReason;
|
||||
private String mark;
|
||||
//一般信息
|
||||
private String information;
|
||||
//主诉
|
||||
@@ -40,15 +40,19 @@ public class MedicalRecords {
|
||||
//诊断
|
||||
private String diagnosis;
|
||||
//治疗方案
|
||||
private String treatmentPlan;
|
||||
private String treatmentPlan="";
|
||||
//图片
|
||||
private String img="";
|
||||
//原始数据
|
||||
private String data;
|
||||
private String data="";
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private MyUserEntity user;
|
||||
@TableField(exist = false)
|
||||
private Integer labelId;
|
||||
@TableField(exist = false)
|
||||
|
||||
Reference in New Issue
Block a user