1: 增加新增电子病历接口

dev_3.1.0
xueqingkun 10 months ago
parent 320ed98d67
commit 99f477f1f2

@ -137,10 +137,17 @@ public class MedicalRecManageController {
return medicalRecManageService.updateMedicalStatus(medicalRecId,status); return medicalRecManageService.updateMedicalStatus(medicalRecId,status);
} }
@Operation(summary = "新建病历基本信息")
@PostMapping("createMedicalRecBaseInfo")
public String createMedicalRecBaseInfo(@RequestBody MedicalRecBaseInfoReqVo reqVO) {
return medicalRecManageService.createMedicalRecBaseInfo(reqVO);
}
@Operation(summary = "保存病历基本信息") @Operation(summary = "保存病历基本信息")
@PostMapping("saveMedicalRecBaseInfo") @PostMapping("saveMedicalRec")
public String saveMedicalRecBaseInfo(@RequestBody MedicalRecBaseInfoReqVo reqVO) { public String saveMedicalRec(@RequestBody MedicalRecInfoReqVo reqVO) {
return medicalRecManageService.saveMedicalRecBaseInfo(reqVO); return medicalRecManageService.saveMedicalRec(reqVO);
} }

@ -0,0 +1,163 @@
package com.supervision.manage.dto;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.supervision.manage.pojo.vo.MedicalRecInfoReqVo;
import com.supervision.model.MedicalExtendItem;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class MedicalExtendInfoDTO {
/**
* id
*/
private static final String patientHistoryItemId = "1020";
/**
* id
*/
private static final String patientPersonalHistoryItemId = "1007";
/**
* id
*/
private static final String patientPastHistoryItemId = "1022";
/**
* id
*/
private static final String patientFamilyHistoryItemId = "1021";
/**
*
*/
private static final String patientSurgeryHistoryItemId = "1055";
/**
*
*/
private static final String patientAllergyItemId = "1048";
private MedicalRecInfoReqVo medicalRecInfo;
public MedicalExtendInfoDTO(MedicalRecInfoReqVo medicalRecInfo) {
this.medicalRecInfo = medicalRecInfo;
}
/**
* extendInfoList
*/
public List<MedicalExtendItem> medicalRecInfoReqVo2ExtendInfoList(){
List<MedicalExtendItem> extendInfoList = new ArrayList<>();
String patientHistory = medicalRecInfo.getPatientHistory();
if (StrUtil.isNotEmpty(patientHistory)){
extendInfoList.add(
this.buildMedicalExtendItem(medicalRecInfo.getId(),patientHistoryItemId,"现病史",patientHistory));
}
String patientAllergy = medicalRecInfo.getPatientAllergy();
if (StrUtil.isNotEmpty(patientAllergy)){
extendInfoList.add(
this.buildMedicalExtendItem(medicalRecInfo.getId(),patientAllergyItemId,"过敏史",patientAllergy));
}
String patientFamilyHistory = medicalRecInfo.getPatientFamilyHistory();
if (StrUtil.isNotEmpty(patientFamilyHistory)){
extendInfoList.add(
this.buildMedicalExtendItem(medicalRecInfo.getId(),patientPersonalHistoryItemId,"个人史",patientFamilyHistory));
}
String patientPersonalHistory = medicalRecInfo.getPatientPersonalHistory();
if (StrUtil.isNotEmpty(patientPersonalHistory)){
extendInfoList.add(
this.buildMedicalExtendItem(medicalRecInfo.getId(),patientFamilyHistoryItemId,"家族史",patientPersonalHistory));
}
String patientPastHistory = medicalRecInfo.getPatientPastHistory();
if (StrUtil.isNotEmpty(patientPastHistory)){
extendInfoList.add(
this.buildMedicalExtendItem(medicalRecInfo.getId(),patientPastHistoryItemId,"既往史",patientPastHistory));
}
String patientSurgeryHistory = medicalRecInfo.getPatientSurgeryHistory();
if (StrUtil.isNotEmpty(patientSurgeryHistory)){
extendInfoList.add(
this.buildMedicalExtendItem(medicalRecInfo.getId(),patientSurgeryHistoryItemId,"手术史",patientSurgeryHistory));
}
List<MedicalRecInfoReqVo.MedicalExtendInfo> reqExtendInfo = medicalRecInfo.getExtendInfoList();
if (CollUtil.isNotEmpty(reqExtendInfo)){
for (MedicalRecInfoReqVo.MedicalExtendInfo info : reqExtendInfo) {
extendInfoList.add(
this.buildMedicalExtendItem(medicalRecInfo.getId(), info.getItemId(),
info.getName(), info.getItemContent()));
}
}
return extendInfoList;
}
/**
* extendInfoList
* @param extendInfoList
*/
public void extendInfoListSetMedicalRecInfoReqVo(List<MedicalExtendItem> extendInfoList){
if (CollUtil.isEmpty(extendInfoList)){
return;
}
List<MedicalRecInfoReqVo.MedicalExtendInfo> medicalExtendInfos = new ArrayList<>();
for (MedicalExtendItem extendItem : extendInfoList) {
String itemId = extendItem.getItemId();
MedicalRecInfoReqVo.MedicalExtendInfo medicalExtendInfo = new MedicalRecInfoReqVo.MedicalExtendInfo();
medicalExtendInfo.setMedicalId(medicalRecInfo.getId());
medicalExtendInfo.setName(extendItem.getName());
medicalExtendInfo.setItemContent(extendItem.getItemContent());
medicalExtendInfo.setItemId(itemId);
if (StrUtil.isEmpty(itemId)){
medicalExtendInfos.add(medicalExtendInfo);
continue;
}
medicalExtendInfo.setItemId(itemId);
switch (itemId){
case patientPersonalHistoryItemId:
medicalRecInfo.setPatientPersonalHistory(extendItem.getItemContent());
break;
case patientFamilyHistoryItemId:
medicalRecInfo.setPatientFamilyHistory(extendItem.getItemContent());
break;
case patientPastHistoryItemId:
medicalRecInfo.setPatientPastHistory(extendItem.getItemContent());
break;
case patientSurgeryHistoryItemId:
medicalRecInfo.setPatientSurgeryHistory(extendItem.getItemContent());
break;
case patientAllergyItemId:
medicalRecInfo.setPatientAllergy(extendItem.getItemContent());
break;
case patientHistoryItemId:
medicalRecInfo.setPatientHistory(extendItem.getItemContent());
break;
default:
medicalExtendInfos.add(medicalExtendInfo);
}
}
}
private MedicalExtendItem buildMedicalExtendItem(String medicalId,String itemId,String name,String itemContent){
MedicalExtendItem medicalExtendItem = new MedicalExtendItem();
medicalExtendItem.setMedicalId(medicalId);
medicalExtendItem.setItemId(itemId);
medicalExtendItem.setName(name);
medicalExtendItem.setItemContent(itemContent);
return medicalExtendItem;
}
}

@ -0,0 +1,53 @@
package com.supervision.manage.pojo.vo;
import com.supervision.model.MedicalRec;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
public class MedicalRecInfoReqVo extends MedicalRec {
@Schema(description = "现病史")
private String patientHistory;
@Schema(description = "过敏史")
private String patientAllergy;
@Schema(description = "个人史")
private String patientFamilyHistory;
@Schema(description = "家族史")
private String patientPersonalHistory;
@Schema(description = "既往史")
private String patientPastHistory;
@Schema(description = "手术史")
private String patientSurgeryHistory;
@Schema(description = "扩展信息")
private List<MedicalExtendInfo> extendInfoList;
@Data
public static class MedicalExtendInfo{
@Schema(description = "病历id")
private String medicalId;
@Schema(description = "类目id")
private String itemId;
@Schema(description = "分类名")
private String name;
@Schema(description = "类目内容")
private String itemContent;
public MedicalExtendInfo() {
}
}
}

@ -48,5 +48,7 @@ public interface MedicalRecManageService {
Boolean updateMedicalStatus(String medicalRecId, Integer status); Boolean updateMedicalStatus(String medicalRecId, Integer status);
String saveMedicalRecBaseInfo(MedicalRecBaseInfoReqVo reqVO); String createMedicalRecBaseInfo(MedicalRecBaseInfoReqVo reqVO);
String saveMedicalRec(MedicalRecInfoReqVo reqVO);
} }

@ -8,6 +8,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.exception.BusinessException; import com.supervision.exception.BusinessException;
import com.supervision.manage.dto.MedicalExtendInfoDTO;
import com.supervision.manage.pojo.vo.*; import com.supervision.manage.pojo.vo.*;
import com.supervision.manage.service.*; import com.supervision.manage.service.*;
import com.supervision.model.*; import com.supervision.model.*;
@ -63,6 +64,8 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
private final ProcessService processService; private final ProcessService processService;
private final MedicalExtendItemService medicalExtendItemService;
public List<Disease> queryDiseaseListByDropList() { public List<Disease> queryDiseaseListByDropList() {
return diseaseService.lambdaQuery().list(); return diseaseService.lambdaQuery().list();
} }
@ -413,7 +416,8 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
} }
@Override @Override
public String saveMedicalRecBaseInfo(MedicalRecBaseInfoReqVo reqVO) { @Transactional(rollbackFor = Exception.class)
public String createMedicalRecBaseInfo(MedicalRecBaseInfoReqVo reqVO) {
Assert.notEmpty(reqVO.getPatientName(), "患者姓名不能为空"); Assert.notEmpty(reqVO.getPatientName(), "患者姓名不能为空");
Assert.notEmpty(reqVO.getPatientGender(), "患者性别不能为空"); Assert.notEmpty(reqVO.getPatientGender(), "患者性别不能为空");
@ -424,9 +428,48 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
MedicalRec medicalRec = reqVO.toMedicalRec(); MedicalRec medicalRec = reqVO.toMedicalRec();
medicalRec.setStatus(0); medicalRec.setStatus(0);
medicalRec.insert(); medicalRec.insert();
// 这里生成一个新的编号(首先去数据库里面查询编号,然后用最大的编号+1)(可能存在并发修改导致编码重复问题,不是重点,等有问题再说)
medicalRecService.updateMedicalRecNo("QL", "男".equals(reqVO.getPatientGender()) ? "M" : "F", medicalRec.getId());
return medicalRec.getId(); return medicalRec.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public String saveMedicalRec(MedicalRecInfoReqVo reqVO) {
// 必填校验
saveMedicalRecAssert(reqVO);
// 更新病历信息
medicalRecService.updateById(reqVO);
// 更新病历扩展信息
medicalExtendItemService.lambdaUpdate().eq(MedicalExtendItem::getMedicalId, reqVO.getId()).remove();
MedicalExtendInfoDTO medicalExtendInfoDTO = new MedicalExtendInfoDTO(reqVO);
List<MedicalExtendItem> medicalExtendItems = medicalExtendInfoDTO.medicalRecInfoReqVo2ExtendInfoList();
medicalExtendItemService.saveOrUpdateBatch(medicalExtendItems);
return reqVO.getId();
}
private void saveMedicalRecAssert(MedicalRecInfoReqVo reqVO){
Assert.notEmpty(reqVO.getId(), "id不能为空");
Assert.notEmpty(reqVO.getPatientId(),"病人id不能为空");
Assert.notEmpty(reqVO.getDiseaseId(), "初步诊断不能为空");
Assert.notEmpty(reqVO.getPatientName(), "患者姓名不能为空");
Assert.notEmpty(reqVO.getPatientGender(), "患者性别不能为空");
Assert.notNull(reqVO.getPatientAge(), "患者年龄不能为空");
Assert.notEmpty(reqVO.getPatientMarriage(), "患者婚姻状态不能为空");
Assert.notEmpty(reqVO.getNativePlace(), "患者籍贯不能为空");
Assert.notEmpty(reqVO.getPatientSelfDesc(), "患者主诉不能为空");
Assert.notEmpty(reqVO.getPatientAllergy(), "患者过敏史不能为空");
Assert.notEmpty(reqVO.getPatientHistory(), "患者现病史不能为空");
Assert.notEmpty(reqVO.getPatientPersonalHistory(), "患者家族史不能为空");
Assert.notEmpty(reqVO.getPatientSurgeryHistory(), "患者手术史不能为空");
Assert.notEmpty(reqVO.getPatientFamilyHistory(), "患者个人史不能为空");
Assert.notEmpty(reqVO.getPatientPastHistory(), "患者既往史不能为空");
} }
} }

@ -103,7 +103,6 @@ public class MedicalRec extends Model<MedicalRec> implements Serializable {
/** /**
* ID * ID
*/ */
@Deprecated
private String patientId; private String patientId;
/** /**

Loading…
Cancel
Save