diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 2f7d1f7a..98353152 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -594,8 +594,65 @@ namespace IRaCIS.Core.Application.Image.QA [HttpPut("{trialId:guid}/{subjectVisitId:guid}/{studyId:guid}/{seriesId:guid}/{state:int}")] [TypeFilter(typeof(TrialResourceFilter))] [Authorize(Policy = IRaCISPolicy.IQC)] - public async Task SetSeriesState(Guid subjectVisitId, Guid studyId, Guid seriesId, int state + public async Task SetSeriesState(Guid subjectVisitId, Guid studyId, Guid seriesId, int state) + { + await VerifyIsCanQCAsync(null, subjectVisitId); + + var series = (await _repository.Where(t => t.Id == seriesId, true).IgnoreQueryFilters().FirstOrDefaultAsync()).IfNullThrowException(); + + + if (state == 1) + { + series.IsReading = false; + } + else if (state == 2) + { + series.IsReading = true; + } + else if (state == 4) + { + series.IsDeleted = true; + + var study = (await _repository.Where(t => t.Id == studyId, true).IgnoreQueryFilters().FirstOrDefaultAsync()).IfNullThrowException(); + + var instanceIdList = await _repository.Where(t => t.SeriesId == seriesId).Select(t => t.Id).ToListAsync(); + + //instanceIdList.ForEach(t => + //{ + // var path = _dicomFileStoreHelper.GetInstanceFilePath(study, seriesId, t.ToString()); + + // if (System.IO.File.Exists(path)) + // { + // File.Delete(path); + // } + + //}); + + study.InstanceCount = study.InstanceCount - instanceIdList.Count; + study.SeriesCount = study.SeriesCount - 1; + + study.IsDeleted = study.SeriesCount == 0; + + } + else if (state == 5) + { + series.IsDeleted = false; + + var study = (await _repository.Where(t => t.Id == studyId, true).IgnoreQueryFilters().FirstOrDefaultAsync()).IfNullThrowException(); + + + var instanceIdList = await _repository.Where(t => t.SeriesId == seriesId).Select(t => t.Id).ToListAsync(); + + study.InstanceCount = study.InstanceCount + instanceIdList.Count; + + study.SeriesCount = study.SeriesCount + 1; + + study.IsDeleted = study.SeriesCount == 0; + } + + return ResponseOutput.Ok(await _repository.SaveChangesAsync()); + } /// ///type 1 :study 2: series 3:非dicom QC修改检查部位和 拍片类型