diff --git a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs index 24d66c4a8..de6a115ee 100644 --- a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs @@ -497,5 +497,68 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Ok(true); } + /// + /// CRC 取消确认 + /// + /// + /// + [HttpPost] + public async Task CRCCancelConfirmClinical(CRCCancelConfirmClinicalInDto inDto) + { + var dataList = await this.GetCRCConfirmList(new GetCRCConfirmListInDto() + { + TrialId = inDto.TrialId + }); + + var presentData = dataList.Where(x => x.ReadModuleId == inDto.ReadModuleId).First(); + + if (dataList.Any(x => x.IsPMConfirm && x.LatestScanDate > presentData.LatestScanDate && x.ReadingSetType == presentData.ReadingSetType)) + { + throw new BusinessValidationFailedException("当前数据并非最后一条确认信息,无法取消!"); + } + + if(presentData.IsPMConfirm) + { + throw new BusinessValidationFailedException("PM已确认,无法取消!"); + } + + + await _readModuleRepository.UpdatePartialFromQueryAsync(x => presentData.ReadModuleId==x.Id, x => new ReadModule() + { + IsCRCConfirm = false + }); + + await _readModuleCriterionFromRepository.BatchDeleteNoTrackingAsync(x=>x.ReadModuleId== presentData.ReadModuleId); + + await _readModuleCriterionFromRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(true); + } + + /// + /// PM确认临床数据 + /// + /// + /// + /// + [HttpPost] + public async Task PMConfirmClinical(CRCConfirmClinicalInDto inDto) + { + var readModuleData = await _readModuleRepository.Where(x => x.Id == inDto.ReadModuleId).FirstNotNullAsync(); + if (!readModuleData.IsCRCConfirm) + { + throw new BusinessValidationFailedException("CRC还未确认数据,PM无法确认"); + } + + await _readModuleRepository.UpdatePartialFromQueryAsync(x => inDto.ReadModuleId == x.Id, x => new ReadModule() + { + IsPMConfirm = false + }); + + await _readModuleRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(true); + } + } } diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs index 88523ebfe..2f242db0b 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs @@ -99,7 +99,14 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid TrialId { get; set; } } - public class CRCConfirmClinicalInDto + public class CRCCancelConfirmClinicalInDto + { + public Guid TrialId { get; set; } + + public Guid ReadModuleId { get; set; } + } + + public class CRCConfirmClinicalInDto { public Guid TrialId { get; set; }