新增了出院时间诊断-未完成,新增了新增病例时,时间判断

This commit is contained in:
wucongxing8150 2025-07-09 09:05:37 +08:00
parent 71db0a5ca3
commit 1a44eedc8f
5 changed files with 179 additions and 80 deletions

View File

@ -79,21 +79,21 @@ public class MedicalRecordAddForm {
/*************************实验室数据***************************/
@ApiModelProperty(value = "治疗前 检测时间", required = true)
@NotNull(message = "治疗前 检测时间 不能为空")
@ApiModelProperty(value = "首次人工肝治疗前检测时间", required = true)
@NotNull(message = "首次人工肝治疗前检测时间 不能为空")
private LocalDateTime headTime;
/**
* 治疗后 检测时间
*/
@ApiModelProperty(value = "治疗后 检测时间 ", required = true)
@NotNull(message = "治疗后 检测时间 不能为空")
@ApiModelProperty(value = "首次人工肝治疗后检测时间 ", required = true)
@NotNull(message = "首次人工肝治疗后检测时间 不能为空")
private LocalDateTime afterTime;
/**
* 最后一次治疗后 检测时间
*/
@ApiModelProperty(value = "最后一次治疗后 检测时间 ", required = true)
@ApiModelProperty(value = "最后一次人工肝治疗后检测时间 检测时间 ", required = true)
private LocalDateTime lastTime;
/**

View File

@ -418,8 +418,14 @@ public class MedicalRecordService {
return ResponseDTO.error(PROJECT_CLOSE);
}
// 检测所有时间
ResponseDTO check = checkAllTime(form);
if(!check.getOk()){
return check;
}
// 检测基本信息
ResponseDTO check = checkCase(form, expertId);
check = checkCase(form, expertId);
if(!check.getOk()){
return check;
}
@ -445,10 +451,121 @@ public class MedicalRecordService {
return ResponseDTO.app_ok();
}
// 检测所有时间
public ResponseDTO checkAllTime(MedicalRecordUpdateForm form){
// 基础时间
LocalDateTime admissionTime = form.getAdmissionTime();
LocalDateTime dischargeTime = form.getDischargeTime();
LocalDateTime headTime = form.getHeadTime();
LocalDateTime afterTime = form.getAfterTime();
LocalDateTime lastTime = form.getLastTime();
List<DpmsAddForm> dpmas = form.getDpmas();
// 时间基准线
LocalDateTime targetDate = LocalDateTime.of(2024, 10, 1, 0, 0);
// 1. 所有时间必须 >= 2024-10-01允许等于
if (!admissionTime.isEqual(targetDate) && !admissionTime.isAfter(targetDate)) {
return ResponseDTO.userErrorParam("入院时间需在2024年10月1日或之后");
}
if (!dischargeTime.isEqual(targetDate) && !dischargeTime.isAfter(targetDate)) {
return ResponseDTO.userErrorParam("出院时间需在2024年10月1日或之后");
}
if (!headTime.isEqual(targetDate) && !headTime.isAfter(targetDate)) {
return ResponseDTO.userErrorParam("首次人工肝治疗前检测时间需在2024年10月1日或之后");
}
if (!afterTime.isEqual(targetDate) && !afterTime.isAfter(targetDate)) {
return ResponseDTO.userErrorParam("首次人工肝治疗后检测时间需在2024年10月1日或之后");
}
for (DpmsAddForm dpma : dpmas) {
LocalDateTime treatTime = dpma.getTreatTime();
if (!treatTime.isEqual(targetDate) && !treatTime.isAfter(targetDate)) {
return ResponseDTO.userErrorParam("人工肝治疗时间需在2024年10月1日或之后");
}
}
if (lastTime != null) {
if (!lastTime.isEqual(targetDate) && !lastTime.isAfter(targetDate)) {
return ResponseDTO.userErrorParam("最后一次人工肝治疗后检测时间需在2024年10月1日或之后");
}
}
// 2. 出院时间必须大于入院时间
if (dpmas.size() > 1){
if (!dischargeTime.isAfter(admissionTime)) {
return ResponseDTO.userErrorParam("出院时间必须大于入院时间");
}
}
// 3. 所有时间必须在入院与出院之间含当天
if (headTime.isBefore(admissionTime) || headTime.isAfter(dischargeTime)) {
return ResponseDTO.userErrorParam("首次人工肝治疗前检测时间必须在入院和出院时间之间");
}
if (afterTime.isBefore(admissionTime) || afterTime.isAfter(dischargeTime)) {
return ResponseDTO.userErrorParam("首次人工肝治疗后检测时间必须在入院和出院时间之间");
}
if (lastTime != null && (lastTime.isBefore(admissionTime) || lastTime.isAfter(dischargeTime))) {
return ResponseDTO.userErrorParam("最后一次人工肝治疗后检测时间必须在入院和出院时间之间");
}
for (DpmsAddForm dpma : dpmas) {
LocalDateTime treatTime = dpma.getTreatTime();
if (treatTime.isBefore(admissionTime) || treatTime.isAfter(dischargeTime)) {
return ResponseDTO.userErrorParam("人工肝治疗时间必须在入院和出院时间之间");
}
}
// 4. 治疗时间不能是同一天且必须递增
for (int i = 0; i < dpmas.size(); i++) {
DpmsAddForm current = dpmas.get(i);
for (int j = i + 1; j < dpmas.size(); j++) {
DpmsAddForm next = dpmas.get(j);
if (current.getTreatTime().toLocalDate().isEqual(next.getTreatTime().toLocalDate())) {
return ResponseDTO.userErrorParam("人工肝治疗时间不能为同一天:" + current.getTreatTime().toLocalDate());
}
}
}
for (int i = 1; i < dpmas.size(); i++) {
LocalDateTime prev = dpmas.get(i - 1).getTreatTime();
LocalDateTime curr = dpmas.get(i).getTreatTime();
if (curr.isBefore(prev)) {
return ResponseDTO.userErrorParam("" + (i + 1) + " 次治疗时间必须晚于第 " + i + "");
}
}
// 5. 时间顺序关系校验
LocalDateTime firstTreatTime = dpmas.get(0).getTreatTime();
if (headTime.isAfter(firstTreatTime)) {
return ResponseDTO.userErrorParam("首次人工肝治疗前检测时间必须早于第一次治疗时间");
}
if (afterTime.isBefore(firstTreatTime)) {
return ResponseDTO.userErrorParam("首次人工肝治疗后检测时间必须在第一次治疗时间之后");
}
if (dpmas.size() > 1) {
if (lastTime == null) {
return ResponseDTO.userErrorParam("人工肝治疗次数大于1需填入最后一次人工肝治疗后检测时间");
}
LocalDateTime lastTreatTime = dpmas.get(dpmas.size() - 1).getTreatTime();
if (lastTime.isBefore(lastTreatTime)) {
return ResponseDTO.userErrorParam("最后一次人工肝治疗后检测时间必须在最后一次治疗时间之后");
}
if (lastTime.isAfter(dischargeTime)) {
return ResponseDTO.userErrorParam("最后一次人工肝治疗后检测时间必须在出院时间之前");
}
}
return ResponseDTO.app_ok();
}
// 检测基本信息
public ResponseDTO checkCase(MedicalRecordUpdateForm form, Long expertId){
//入院时间
LocalDateTime admissionTime = form.getAdmissionTime();
//患者id
String uid = form.getUid();
@ -461,6 +578,9 @@ public class MedicalRecordService {
.map(MedicalRecordUserEntity::getId)
.distinct() // 可选去重
.collect(Collectors.toList());
if (!userIds.isEmpty()){
return ResponseDTO.userErrorParam("请勿上传重复病例");
}
// 获取该患者的全部病例
LambdaQueryWrapper<MedicalRecordEntity> medicalRecordQueryWrapper = new LambdaQueryWrapper<>();
@ -468,10 +588,10 @@ public class MedicalRecordService {
List<MedicalRecordEntity> medicalRecords = medicalRecorDao.selectList(medicalRecordQueryWrapper);
for (MedicalRecordEntity medicalRecord: medicalRecords) {
// 判断是否是今天
// 同一个患者ID可以提交多份病例(入院时间不同)所有病例对比
boolean isSameDate = medicalRecord.getAdmissionTime().toLocalDate().isEqual(admissionTime.toLocalDate());
// 同一个患者ID可以提交多份病例(入院时间不同入院时间不同)所有病例对比
boolean isSameDate = medicalRecord.getAdmissionTime().toLocalDate().isEqual(form.getAdmissionTime().toLocalDate());
if (isSameDate){
return ResponseDTO.userErrorParam("患者入院时间和其他病例出现重复");
return ResponseDTO.userErrorParam("请勿上传重复病例");
}
}
}
@ -490,26 +610,7 @@ public class MedicalRecordService {
public ResponseDTO checkDpms(MedicalRecordUpdateForm form, Long expertId){
List<DpmsAddForm> dpmas = form.getDpmas();
// 治疗时间
LocalDateTime target = LocalDateTime.of(2024, 10, 1, 0, 0);
boolean isAfter = dpmas.get(0).getTreatTime().isAfter(target);
if (!isAfter){
return ResponseDTO.userErrorParam("第一次治疗时间需在2024年10月1日之后");
}
isAfter = dpmas.get(0).getTreatTime().isAfter(form.getAdmissionTime());
if (!isAfter){
return ResponseDTO.userErrorParam("第1次治疗时间需在入院时间后");
}
for (int i = 1; i < dpmas.size(); i++) {
LocalDateTime previous = dpmas.get(i - 1).getTreatTime();
LocalDateTime current = dpmas.get(i).getTreatTime();
if (current.isBefore(previous) || current.isEqual(previous)) {
throw new IllegalArgumentException("" + (i + 1) + " 次治疗时间必须晚于第 " + i + "");
}
String dpmasImg = dpmas.get(i - 1).getDpmasImg();
String[] dpmasImgNum = dpmasImg.split(",");
if(dpmasImgNum.length > 3){
@ -522,28 +623,6 @@ public class MedicalRecordService {
// 实验室检测
public ResponseDTO checkData(MedicalRecordUpdateForm form, Long expertId){
if (form.getHeadTime() == null) {
return ResponseDTO.userErrorParam("首次人工肝治疗前检测时间不能为空");
}
if (form.getAfterTime() == null) {
return ResponseDTO.userErrorParam("首次人工肝治疗后检测时间不能为空");
}
if (!form.getHeadTime().isBefore(form.getAfterTime())) {
return ResponseDTO.userErrorParam("首次人工肝治疗前检测时间需早于首次人工肝治疗后检测时间");
}
if (form.getLastTime() != null && !form.getAfterTime().isBefore(form.getLastTime())) {
return ResponseDTO.userErrorParam("最后一次人工肝治疗后检测时间需早于首次人工肝治疗后检测时间");
}
if (form.getDpmas().size() > 1){
if (form.getLastTime() == null){
return ResponseDTO.userErrorParam("人工肝治疗次数大于1需填入最后一次人工肝治疗后检测时间");
}
}
String checkImg = form.getCheckImg();
String[] checkImgNum = checkImg.split(",");
if(checkImgNum.length > 6){
@ -559,27 +638,23 @@ public class MedicalRecordService {
LocalDateTime dischargeTime = form.getDischargeTime();
List<DpmsAddForm> dpmas = form.getDpmas();
if (admissionTime == null || dischargeTime == null) {
throw new IllegalArgumentException("入院时间和出院时间不能为空");
}
// 出院时间大于住院时间
boolean isAfter = dischargeTime.isAfter(admissionTime);
if (!isAfter){
return ResponseDTO.userErrorParam("疾病转归:出院时间需大于住院时间");
}
// boolean isAfter = dischargeTime.isAfter(admissionTime);
// if (!isAfter){
// return ResponseDTO.userErrorParam("疾病转归:出院时间需大于住院时间");
// }
for (int i = 0; i < dpmas.size(); i++) {
LocalDateTime treatTime = dpmas.get(i).getTreatTime();
if (treatTime == null) {
return ResponseDTO.userErrorParam("人工肝治疗:" + "" + (i + 1) + " 次治疗时间不能为空");
}
if (treatTime.isBefore(admissionTime) || treatTime.isAfter(dischargeTime)) {
return ResponseDTO.userErrorParam("人工肝治疗:" + "" + (i + 1) + " 次治疗时间不在入院和出院时间之间");
}
}
// for (int i = 0; i < dpmas.size(); i++) {
// LocalDateTime treatTime = dpmas.get(i).getTreatTime();
//
// if (treatTime == null) {
// return ResponseDTO.userErrorParam("人工肝治疗:" + "" + (i + 1) + " 次治疗时间不能为空");
// }
//
// if (treatTime.isBefore(admissionTime) || treatTime.isAfter(dischargeTime)) {
// return ResponseDTO.userErrorParam("人工肝治疗:" + "" + (i + 1) + " 次治疗时间不在入院和出院时间之间");
// }
// }
return ResponseDTO.app_ok();
}

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation;
import net.lab1024.sa.admin.module.app.medicalrecord.domain.MedicalRecordDetailVO;
import net.lab1024.sa.admin.module.app.medicalrecord.service.MedicalRecordService;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CancelExamineForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseMainDiagnoseForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseplatformCaseQueryForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseplatformCaseUpdateForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseDetailVO;
@ -16,11 +17,7 @@ import net.lab1024.sa.common.common.util.SmartEasyPoiExcelUtil;
import net.lab1024.sa.common.module.support.operatelog.annoation.OperateLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@ -106,4 +103,12 @@ public class CaseplatformCaseController {
e.printStackTrace();
}
}
@ApiOperation("出院诊断修改")
@PutMapping("/caseplatformCase/mainDiagnose")
@PreAuthorize("@saAuth.checkPermission('case-system:case:mainDiagnose')")
public ResponseDTO<String> caseMainDiagnose(@RequestBody @Valid CaseMainDiagnoseForm form) {
return ResponseDTO.ok();
}
}

View File

@ -0,0 +1,13 @@
package net.lab1024.sa.admin.module.business.caseplatformcase.domain.form;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class CaseMainDiagnoseForm {
@ApiModelProperty(value = "出院诊断照片", required = true)
@NotNull(message = "出院诊断照片 不能为空")
private String mainDiagnoseImg;
}

View File

@ -15,10 +15,7 @@ import net.lab1024.sa.admin.module.app.expert.domain.entity.CasePlatformBankEnti
import net.lab1024.sa.admin.module.business.area.domain.vo.ProvVO;
import net.lab1024.sa.admin.module.business.caseplatformcase.dao.CaseplatformCaseDao;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.entity.CaseplatformCaseEntity;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CancelExamineForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseplatformCaseAddForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseplatformCaseQueryForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseplatformCaseUpdateForm;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.*;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseDetailVO;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseVO;
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.EasyExcelCaseDetailVO;
@ -468,6 +465,15 @@ public class CaseplatformCaseService {
return Math.max(incomeTax, 0); // 防止负值
}
/**
* 出院诊断修改
*
*/
public ResponseDTO<String> caseMainDiagnose(CaseMainDiagnoseForm form) {
return ResponseDTO.ok();
}
/**
* 白名单专家导入
*/