问诊配置
parent
d6a9509294
commit
2449c2163f
@ -0,0 +1,46 @@
|
|||||||
|
package com.supervision.manage.controller.medicalrec;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.supervision.manage.pojo.vo.MedicalRecQaAnswerSaveReqVO;
|
||||||
|
import com.supervision.manage.service.MedicalRecQaService;
|
||||||
|
import com.supervision.model.AskTemplateQuestionLibrary;
|
||||||
|
import com.supervision.vo.manage.MedicalRecQaPageResVO;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Tag(name = "病历管理-临床问诊")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/medicalRecQa")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MedicalRecQaController {
|
||||||
|
|
||||||
|
private final MedicalRecQaService medicalRecQaService;
|
||||||
|
|
||||||
|
@Operation(summary = "病历管理-临床问诊分页查询")
|
||||||
|
@GetMapping("/queryMedicalRecQaPage")
|
||||||
|
public IPage<MedicalRecQaPageResVO> queryMedicalRecQaPage(String medicalRecId, String question, Integer basisConfirmFlag, Integer pageNum, Integer pageSize) {
|
||||||
|
Assert.notBlank(medicalRecId, "病历ID不能为空");
|
||||||
|
return medicalRecQaService.queryMedicalRecQaPage(medicalRecId, question, basisConfirmFlag, pageNum, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "病历管理-临床问诊可选问题列表")
|
||||||
|
@GetMapping("/queryMedicalRecQaPage")
|
||||||
|
public IPage<AskTemplateQuestionLibrary> queryMedicalRecQaToSelectPage(String medicalRecId, Long dictId, String question, Integer pageNum, Integer pageSize) {
|
||||||
|
return medicalRecQaService.queryMedicalRecQaToSelectPage(medicalRecId, dictId, question, pageNum, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "病历管理-临床问诊可选问题列表")
|
||||||
|
@PostMapping("/saveMedicalRecQaAnswer")
|
||||||
|
public void saveMedicalRecQaAnswer(@RequestBody MedicalRecQaAnswerSaveReqVO reqVO) {
|
||||||
|
medicalRecQaService.saveMedicalRecQaAnswer(reqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "病历管理-删除病历问答")
|
||||||
|
@GetMapping("deleteMedicalRecQa")
|
||||||
|
public void deleteMedicalRecQa(String id) {
|
||||||
|
medicalRecQaService.deleteMedicalRecQa(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.supervision.manage.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MedicalRecQaAnswerSaveReqVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String medicalRecId;
|
||||||
|
|
||||||
|
private String libraryId;
|
||||||
|
|
||||||
|
private String answer;
|
||||||
|
|
||||||
|
private Integer basisConfirmFlag;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.supervision.manage.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.supervision.manage.pojo.vo.MedicalRecQaAnswerSaveReqVO;
|
||||||
|
import com.supervision.model.AskTemplateQuestionLibrary;
|
||||||
|
import com.supervision.vo.manage.MedicalRecQaPageResVO;
|
||||||
|
|
||||||
|
public interface MedicalRecQaService {
|
||||||
|
|
||||||
|
IPage<MedicalRecQaPageResVO> queryMedicalRecQaPage(String medicalRecId,
|
||||||
|
String question,
|
||||||
|
Integer basisConfirmFlag,
|
||||||
|
Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
IPage<AskTemplateQuestionLibrary> queryMedicalRecQaToSelectPage(String medicalRecId, Long dictId, String question, Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
void saveMedicalRecQaAnswer(MedicalRecQaAnswerSaveReqVO reqVO);
|
||||||
|
|
||||||
|
void deleteMedicalRecQa(String id);
|
||||||
|
}
|
@ -0,0 +1,143 @@
|
|||||||
|
package com.supervision.manage.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.supervision.exception.BusinessException;
|
||||||
|
import com.supervision.manage.pojo.vo.MedicalRecQaAnswerSaveReqVO;
|
||||||
|
import com.supervision.manage.service.MedicalRecQaService;
|
||||||
|
import com.supervision.model.AskPatientAnswer;
|
||||||
|
import com.supervision.model.AskTemplateQuestionLibrary;
|
||||||
|
import com.supervision.model.CommonDic;
|
||||||
|
import com.supervision.service.AskPatientAnswerService;
|
||||||
|
import com.supervision.service.AskTemplateQuestionLibraryService;
|
||||||
|
import com.supervision.service.CommonDicService;
|
||||||
|
import com.supervision.vo.manage.MedicalRecQaPageResVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MedicalRecQaServiceImpl implements MedicalRecQaService {
|
||||||
|
|
||||||
|
private final AskPatientAnswerService askPatientAnswerService;
|
||||||
|
|
||||||
|
private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
|
||||||
|
|
||||||
|
private final CommonDicService commonDicService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public IPage<MedicalRecQaPageResVO> queryMedicalRecQaPage(String medicalRecId,
|
||||||
|
String question,
|
||||||
|
Integer basisConfirmFlag,
|
||||||
|
Integer pageNum, Integer pageSize) {
|
||||||
|
IPage<MedicalRecQaPageResVO> page = askPatientAnswerService.queryMedicalRecQaPage(medicalRecId, question, basisConfirmFlag, pageNum, pageSize);
|
||||||
|
if (CollUtil.isNotEmpty(page.getRecords())) {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
// 如果不为空,这时就给生成一些问题和答案(问题是产品给的14个问题)
|
||||||
|
List<String> dictPathList = new ArrayList<>();
|
||||||
|
dictPathList.add("现病史/主诉");
|
||||||
|
dictPathList.add("现病史/症状持续时间");
|
||||||
|
dictPathList.add("现病史/伴随症状");
|
||||||
|
dictPathList.add("现病史/治疗经过");
|
||||||
|
dictPathList.add("现病史/症状演变");
|
||||||
|
dictPathList.add("一般状况/精神状态");
|
||||||
|
dictPathList.add("一般状况/体重");
|
||||||
|
dictPathList.add("既往史/手术史");
|
||||||
|
dictPathList.add("既往史/过敏史");
|
||||||
|
dictPathList.add("既往史/预防接种史");
|
||||||
|
dictPathList.add("一般状况/大小便");
|
||||||
|
dictPathList.add("既往史/慢性病史");
|
||||||
|
dictPathList.add("家族史/遗传倾向");
|
||||||
|
List<CommonDic> dicList = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").list();
|
||||||
|
List<AskPatientAnswer> answerList = new ArrayList<>();
|
||||||
|
if (CollUtil.isNotEmpty(dicList)) {
|
||||||
|
Map<String, Long> dictMap = dicList.stream().collect(Collectors.toMap(CommonDic::getNameZhPath, CommonDic::getId));
|
||||||
|
// 获取找到数据的对应的字典ID
|
||||||
|
Set<Long> dictIdSet = dictPathList.stream().filter(dictMap::containsKey).map(dictMap::get).collect(Collectors.toSet());
|
||||||
|
List<AskTemplateQuestionLibrary> libraryList = askTemplateQuestionLibraryService.lambdaQuery().in(AskTemplateQuestionLibrary::getDictId, dictIdSet).list();
|
||||||
|
if (CollUtil.isNotEmpty(libraryList)) {
|
||||||
|
Map<Long, List<AskTemplateQuestionLibrary>> libraryMap = libraryList.stream().collect(Collectors.groupingBy(AskTemplateQuestionLibrary::getDictId));
|
||||||
|
// 获取到问题
|
||||||
|
for (String dictPath : dictPathList) {
|
||||||
|
// 首先根据字典名称找到对应的dictId
|
||||||
|
Long dictId = dictMap.get(dictPath);
|
||||||
|
if (dictId != null) {
|
||||||
|
List<AskTemplateQuestionLibrary> libraryListByDictId = libraryMap.get(dictId);
|
||||||
|
if (CollUtil.isNotEmpty(libraryListByDictId) && libraryListByDictId.stream().findAny().isPresent()) {
|
||||||
|
// 如果不为空,那就随便找一个
|
||||||
|
AskTemplateQuestionLibrary library = libraryListByDictId.stream().findAny().get();
|
||||||
|
AskPatientAnswer askPatientAnswer = new AskPatientAnswer();
|
||||||
|
askPatientAnswer.setMedicalId(medicalRecId);
|
||||||
|
askPatientAnswer.setLibraryQuestionId(library.getId());
|
||||||
|
askPatientAnswer.setQuestion(library.getStandardQuestion());
|
||||||
|
answerList.add(askPatientAnswer);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
askPatientAnswerService.saveBatch(answerList);
|
||||||
|
// 再查一遍
|
||||||
|
return askPatientAnswerService.queryMedicalRecQaPage(medicalRecId, question, basisConfirmFlag, pageNum, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<AskTemplateQuestionLibrary> queryMedicalRecQaToSelectPage(String medicalRecId, Long dictId, String question, Integer pageNum, Integer pageSize) {
|
||||||
|
// 首先查到已选择的ID
|
||||||
|
List<AskPatientAnswer> answerList = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalRecId).select(AskPatientAnswer::getLibraryQuestionId).list();
|
||||||
|
Set<String> existLibrarySet = answerList.stream().map(AskPatientAnswer::getLibraryQuestionId).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 已选择的不会出现,且自定义的也不会出现
|
||||||
|
return askTemplateQuestionLibraryService.lambdaQuery()
|
||||||
|
.eq(AskTemplateQuestionLibrary::getType, 1)
|
||||||
|
.notIn(CollUtil.isNotEmpty(existLibrarySet), AskTemplateQuestionLibrary::getId, existLibrarySet)
|
||||||
|
.like(StrUtil.isNotBlank(question), AskTemplateQuestionLibrary::getStandardQuestion, question)
|
||||||
|
.eq(ObjectUtil.isNotEmpty(dictId), AskTemplateQuestionLibrary::getDictId, dictId).page(new Page<>(pageNum, pageSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void saveMedicalRecQaAnswer(MedicalRecQaAnswerSaveReqVO reqVO) {
|
||||||
|
Assert.notBlank(reqVO.getId(), "ID不能为空");
|
||||||
|
Assert.notBlank(reqVO.getMedicalRecId(), "病历ID不能为空");
|
||||||
|
Assert.notBlank(reqVO.getAnswer(), "答案不能为空");
|
||||||
|
Assert.notBlank(reqVO.getLibraryId(), "问题ID不能为空");
|
||||||
|
Optional<AskPatientAnswer> askPatientAnswerOpt = askPatientAnswerService.getOptById(reqVO.getId());
|
||||||
|
|
||||||
|
if (askPatientAnswerOpt.isPresent()) {
|
||||||
|
AskPatientAnswer askPatientAnswer = askPatientAnswerOpt.get();
|
||||||
|
askPatientAnswer.setAnswer(reqVO.getAnswer());
|
||||||
|
askPatientAnswerService.updateById(askPatientAnswer);
|
||||||
|
} else {
|
||||||
|
Optional<AskTemplateQuestionLibrary> optById = askTemplateQuestionLibraryService.getOptById(reqVO.getLibraryId());
|
||||||
|
AskTemplateQuestionLibrary library = optById.orElseThrow(() -> new BusinessException("未找到的标准问题"));
|
||||||
|
AskPatientAnswer answer = new AskPatientAnswer();
|
||||||
|
answer.setMedicalId(answer.getMedicalId());
|
||||||
|
answer.setLibraryQuestionId(answer.getLibraryQuestionId());
|
||||||
|
answer.setQuestion(library.getStandardQuestion());
|
||||||
|
answer.setAnswer(answer.getAnswer());
|
||||||
|
askPatientAnswerService.save(answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteMedicalRecQa(String id) {
|
||||||
|
Assert.notBlank(id, "ID不能为空");
|
||||||
|
askPatientAnswerService.removeById(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.supervision.vo.manage;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema
|
||||||
|
public class MedicalRecQaPageResVO {
|
||||||
|
|
||||||
|
@Schema(description = "本条记录ID,删除更新都用它")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "标准问题库ID")
|
||||||
|
private String libraryId;
|
||||||
|
|
||||||
|
@Schema(description = "标准问题")
|
||||||
|
private String standardQuestion;
|
||||||
|
|
||||||
|
@Schema(description = "问题类型 1标准问 2自定义问题")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@Schema(description = "回答")
|
||||||
|
private String answer;
|
||||||
|
|
||||||
|
@Schema(description = "问题类目")
|
||||||
|
private String dictPath;
|
||||||
|
|
||||||
|
@Schema(description = "字典ID")
|
||||||
|
private Long dictId;
|
||||||
|
|
||||||
|
@Schema(description = "是否是证实诊断依据(0否1是)")
|
||||||
|
private Integer basisConfirmFlag;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue