diff --git a/IRaCIS.Core.API/Controllers/StudyController.cs b/IRaCIS.Core.API/Controllers/StudyController.cs index cbeaf3caa..225648667 100644 --- a/IRaCIS.Core.API/Controllers/StudyController.cs +++ b/IRaCIS.Core.API/Controllers/StudyController.cs @@ -230,19 +230,7 @@ namespace IRaCIS.Api.Controllers await _inspectionService.AddInspectionRecordAsync(data); - List datas = new List(); - datas.Add(new DataInspection() - { - - SiteId = savedInfo.SiteId, - SubjectId = savedInfo.SubjectId, - TrialId = savedInfo.TrialId, - SubjectVisitId = savedInfo.SubjectVisitId, - Identification = "Edit|Visit|Status|Visit-Image Upload|Add Image", - JsonDetail = savedInfo.ToJcJson() - }); - - await _inspectionService.AddListInspectionRecordAsync(datas); + return ResponseOutput.Ok(archiveResult); diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs index c6419829b..3cd2e385d 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs @@ -175,24 +175,6 @@ namespace IRaCIS.Core.Application.Services if (isStudyNeedAdd) { - //dicomStudy.Id = NewId.NextGuid(); - - //datas.Add(new DataInspection() - //{ - - // SiteId = dicomStudy.SiteId, - // SubjectId = dicomStudy.SubjectId, - // TrialId = dicomStudy.TrialId, - // SubjectVisitId = dicomStudy.SubjectVisitId, - // CreateTime = createtime, - // GeneralId= dicomStudy.Id, - // Identification = "Edit|Visit|Status|Visit-Image Upload|Add Image", - // JsonDetail = JsonConvert.SerializeObject(new - // { - // SubmitState = "待提交", - // }) - //}); - // 添加检查 await _studyRepository.AddAsync(dicomStudy); } diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 8bbb32ed6..59f9aa672 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -402,7 +402,7 @@ namespace IRaCIS.Core.Application.Service.Inspection public async Task SetEnum(DataInspectionAddDTO Data) { - Data.JsonDetail= await _dataInspectionRepository.SetEnum(Data.Identification, Data.JsonDetail); + Data.JsonDetail= await _dataInspectionRepository.SetEnum(Data.TrialId.Value, Data.Identification, Data.JsonDetail); #region 枚举 //try //{ diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index f0dde4911..7dddd0bf7 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -28,6 +28,7 @@ namespace IRaCIS.Core.Application.Contracts private readonly IHttpContextAccessor _httpContext; private readonly IDictionaryService _dictionaryService; private readonly IInspectionService _inspectionService; + private readonly IRepository _studyMonitorRepository; private readonly IRepository _noneDicomStudyFileRepository; @@ -35,16 +36,18 @@ namespace IRaCIS.Core.Application.Contracts public NoneDicomStudyService(IRepository noneDicomStudyRepository, - IHttpContextAccessor httpContext, - IDictionaryService dictionaryService, - IInspectionService inspectionService, + IHttpContextAccessor httpContext, + IDictionaryService dictionaryService, + IInspectionService inspectionService, + IRepository studyMonitorRepository, IRepository noneDicomStudyFileRepository) { _noneDicomStudyRepository = noneDicomStudyRepository; - + this._httpContext = httpContext; this._dictionaryService = dictionaryService; this._inspectionService = inspectionService; + this._studyMonitorRepository = studyMonitorRepository; _noneDicomStudyFileRepository = noneDicomStudyFileRepository; } @@ -130,20 +133,7 @@ namespace IRaCIS.Core.Application.Contracts var subvisit = await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == subjectVisitId); - // 修改访视状态 - //List datas = new List(); - //datas.Add(new DataInspection() - //{ - - // SiteId = subvisit.SiteId, - // SubjectId = subvisit.SubjectId, - // TrialId = subvisit.TrialId, - // SubjectVisitId = subvisit.Id, - // Identification = "Edit|Visit|Status|Visit-Image Upload|Add Image", - // JsonDetail = subvisit.ToJcJson() - //}); - - //await _inspectionService.AddListInspectionRecordAsync(datas); + return ResponseOutput.Ok(); } @@ -179,23 +169,6 @@ namespace IRaCIS.Core.Application.Contracts var data = JsonConvert.DeserializeObject(fileDto.AuditInfo); data.GeneralId = fileDto.noneDicomStudyId; await _inspectionService.AddInspectionRecordAsync(data); - - var subvisit = await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == fileDto.subjectVisitId); - - List datas = new List(); - datas.Add(new DataInspection() - { - - SiteId = subvisit.SiteId, - SubjectId = subvisit.SubjectId, - TrialId = subvisit.TrialId, - SubjectVisitId = subvisit.Id, - Identification = "Edit|Visit|Status|Visit-Image Upload|Add Image", - JsonDetail = subvisit.ToJcJson() - }); - - - await _inspectionService.AddListInspectionRecordAsync(datas); } return result; @@ -265,7 +238,7 @@ namespace IRaCIS.Core.Application.Contracts // 上传非Dicom 后 将状态改为待提交 分为普通上传 和QC后重传 普通上传时才改为待提交 await _repository.BatchUpdateAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.None, u => new SubjectVisit() { SubmitState = SubmitStateEnum.ToSubmit }); - await _repository.AddAsync(new StudyMonitor() + await _studyMonitorRepository.AddAsync(new StudyMonitor() { FileCount = formCollection.Files.Count, FileSize = formCollection.Files.Sum(t => t.Length), @@ -316,7 +289,7 @@ namespace IRaCIS.Core.Application.Contracts } - await _repository.AddAsync(new NoneDicomStudyFile() { FileName = fileName, Path = relativePath, NoneDicomStudyId = noneDicomStudyId }); + await _noneDicomStudyFileRepository.AddAsync(new NoneDicomStudyFile() { FileName = fileName, Path = relativePath, NoneDicomStudyId = noneDicomStudyId }); } } diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 9821e7b8d..52dd73ce3 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -1043,17 +1043,6 @@ namespace IRaCIS.Core.Application.Image.QA var subvisit = await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == subjectVisitId); - - datas.Add(new DataInspection() - { - - SiteId = subvisit.SiteId, - SubjectId = subvisit.SubjectId, - TrialId = subvisit.TrialId, - SubjectVisitId = subvisit.Id, - Identification = "Edit|Visit|Status|Visit-Image Upload|Add Image", - JsonDetail = subvisit.ToJcJson() - }); await _inspectionService.AddListInspectionRecordAsync(datas); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs index 13b0595db..f860395ed 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs @@ -47,7 +47,7 @@ namespace IRaCIS.Core.Infra.EFCore /// json对象 /// - Task SetEnum(string Identification, string json); + Task SetEnum(Guid trial, string Identification, string json); } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 00a798172..fe2a6f129 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -229,6 +229,8 @@ namespace IRaCIS.Core.Infra.EFCore public async Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) { _dbSet.Remove(entity); + + if (autoSave) { @@ -414,9 +416,6 @@ namespace IRaCIS.Core.Infra.EFCore #endregion #region 不常用 - - - /// EF跟踪方式 生成 部分字段更新 (只更新传递的字段名 new[] {nameof(User.Name), nameof(User.Age)) public async Task UpdatePartialFieldsAsync(TEntity entity, string[] propertyNames, bool autoSave = false, bool ignoreEntityNullProperty = true, params EntityVerifyExp[] verify) @@ -471,10 +470,10 @@ namespace IRaCIS.Core.Infra.EFCore /// Json对象 /// /// - public async Task SetEnum(string Identification, string json) + public async Task SetEnum(Guid trilaid, string Identification, string json) { var list =await (from u in _dbContext.FrontAuditConfig.Where(x=>x.Identification== Identification) - join p in _dbContext.FrontAuditConfig.Where(x=>x.DictionaryCode!=null&& x.DictionaryCode != string.Empty&&x.DictionaryType != null&&x.DictionaryType != string.Empty) on u.Id equals p.ParentId + join p in _dbContext.FrontAuditConfig.Where(x=>x.Code== "AuditState"||(x.DictionaryCode!=null&& x.DictionaryCode != string.Empty&&x.DictionaryType != null&&x.DictionaryType != string.Empty)) on u.Id equals p.ParentId select new { Key= p.Code, @@ -482,6 +481,17 @@ namespace IRaCIS.Core.Infra.EFCore Type= p.DictionaryType }).ToListAsync(); + // 添加单双审 + var trialtype = await _dbContext.Trial.AsQueryable().Where(x => x.Id == trilaid).Select(x => x.QCProcessEnum).FirstOrDefaultAsync(); + + list.Add(new + { + + Key = "AuditState", + Code = trialtype == TrialQCProcess.SingleAudit ? "AuditStateRC" : "AuditStatePE", + Type = "Code", + }); + try { var JsonData = JsonConvert.DeserializeObject>(json); @@ -602,8 +612,47 @@ namespace IRaCIS.Core.Infra.EFCore JsonDetail = entity.ToJcJson() }); } + + // dicom影像 + else if (typeof(TEntity) == typeof(DicomStudy)) + { + DicomStudy data = entity as DicomStudy; + await UpdateSubjectVisit(data.SubjectVisitId, SubmitStateEnum.ToSubmit,"上传Dicom影像"); + } + // 非Dicom影像 + else if (typeof(TEntity) == typeof(NoneDicomStudy)) + { + DicomStudy data = entity as DicomStudy; + await UpdateSubjectVisit(data.SubjectVisitId, SubmitStateEnum.ToSubmit, "上传非Dicom影像"); + } + + // 修改访视状态记录稽查 + async Task UpdateSubjectVisit(Guid subvisitVisit, SubmitStateEnum submit,string reason) + { + var subjectvisit = await _dbContext.SubjectVisit.AsNoTracking().AsQueryable().Where(x => x.Id == subvisitVisit).FirstOrDefaultAsync(); + if (subjectvisit.SubmitState != submit) + { + subjectvisit.SubmitState = submit; + } + + List inspections = new List(); + inspections.Add(new DataInspection() + { + Identification= "Edit|Visit|Status|Visit-Image Upload|Add Image", + TrialId= subjectvisit.TrialId, + SiteId=subjectvisit.SiteId, + SubjectId=subjectvisit.SubjectId, + SubjectVisitId=subjectvisit.Id, + Reason= reason, + JsonDetail= subjectvisit.ToJcJson(), + }); + + } + + await AddListInspectionRecordAsync(datas); } + /// /// 添加稽查记录 /// @@ -633,7 +682,7 @@ namespace IRaCIS.Core.Infra.EFCore { add.CreateTime = DateTime.Now; } - add.JsonDetail = await SetEnum(add.Identification, add.JsonDetail); + add.JsonDetail = await SetEnum(add.TrialId,add.Identification, add.JsonDetail); await SetDataInspectionDateType(add); } @@ -641,6 +690,8 @@ namespace IRaCIS.Core.Infra.EFCore } + + /// /// IsNullOrEmpty /// @@ -691,17 +742,13 @@ namespace IRaCIS.Core.Infra.EFCore { JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); } - } catch (Exception) { - continue; } } - - } Data.JsonDetail = JsonConvert.SerializeObject(JsonData);