diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs index 02c7829ea..693005180 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs @@ -181,37 +181,9 @@ namespace IRaCIS.Core.Application.Services if (isSeriesNeedAdd) { + dicomSeries.DicomStudy = dicomStudy; // 添加序列 await _seriesRepository.AddAsync(dicomSeries); - #region 稽查 - List datas = new List(); - - - // 这里移动不进去 - datas.Add(new DataInspection() - { - - SiteId = dicomStudy.SiteId, - SubjectId = dicomStudy.SubjectId, - TrialId = dicomStudy.TrialId, - GeneralId = dicomSeries.Id, - SubjectVisitId = dicomStudy.SubjectVisitId, - CreateTime = createtime.AddMilliseconds(10), - Identification = "Init|DICOM Series|Status|Visit-Image Upload", - JsonDetail = JsonConvert.SerializeObject(new - { - StudyCode = dicomStudy.StudyCode, - Modalities = dicomStudy.Modalities, - SeriesNumber = dicomSeries.SeriesNumber, - InstanceCount = dicomSeries.InstanceCount, - SeriesTime = dicomSeries.SeriesTime, - IsReading = dicomSeries.IsReading, - IsDeleted = dicomSeries.IsReading, - - }) - }); - await _inspectionService.AddListInspectionRecordAsync(datas); - #endregion } diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 85bd3aa01..9ba84f8fc 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -842,7 +842,7 @@ namespace IRaCIS.Core.Application.Image.QA var DicomSeriesdata = await _repository.GetQueryable().Where(x => x.StudyId == id).ToListAsync(); var study = await _repository.FirstOrDefaultAsync(t => t.Id == id); - List datas = new List(); + DateTime time = DateTime.Now.AddMilliseconds(500); if (type == 1) { @@ -852,33 +852,6 @@ namespace IRaCIS.Core.Application.Image.QA study.BodyPartForEdit = bodyPart; study.Modalities = modality; await _repository.BatchUpdateAsync(t => t.StudyId == id, r => new DicomSeries() { BodyPartForEdit = bodyPart, Modality = modality }); - - DicomSeriesdata.ForEach(x => - { - //datas.Add(new DataInspection() - //{ - // TrialId = x.TrialId, - // SiteId = x.SiteId, - // SubjectId = x.SubjectId, - // SubjectVisitId = x.SubjectVisitId, - // GeneralId = x.Id, - // CreateTime = time, - // Identification = "Edit|DICOM Series|Info|Visit-Image Quanlity Control", - // JsonDetail = JsonConvert.SerializeObject(new - // { - // StudyCode = study.StudyCode, - // Modalities = study.Modalities, - // SeriesNumber = x.SeriesNumber, - // InstanceCount = x.InstanceCount, - // SeriesTime = x.SeriesTime, - // BodyPartForEdit = bodyPart, - // Modality = modality - // }) - - //}); - - }); - } else if (type == 2) { @@ -886,30 +859,6 @@ namespace IRaCIS.Core.Application.Image.QA if (series == null) return Null404NotFound(series); series.BodyPartForEdit = bodyPart; - //DicomSeriesdata.ForEach(x => - //{ - // datas.Add(new DataInspection() - // { - // TrialId = x.TrialId, - // SiteId = x.SiteId, - // SubjectId = x.SubjectId, - // SubjectVisitId = x.SubjectVisitId, - // GeneralId = x.Id, - // CreateTime = time, - // Identification = "Edit|DICOM Series|Info|Visit-Image Quanlity Control", - // JsonDetail = JsonConvert.SerializeObject(new - // { - // StudyCode = study.StudyCode, - // Modalities = study.Modalities, - // SeriesNumber = x.SeriesNumber, - // InstanceCount = x.InstanceCount, - // SeriesTime = x.SeriesTime, - // BodyPartForEdit = bodyPart, - // }) - - // }); - - //}); } else if (type == 3) { @@ -1869,28 +1818,15 @@ namespace IRaCIS.Core.Application.Image.QA { bool isSuccess = false; - List datas = new List(); + foreach (var subjectVisitId in subjectVisitIdList) { var info = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); - Dictionary keyValuePairs = new Dictionary() { - {"SubmitState",info.SubmitState }, - { "AuditState",info.AuditState}, - { "CheckState",info.CheckState}, - { "ForwardState",info.ForwardState} - - }; - DataInspection data = new DataInspection() - { - TrialId = info.TrialId, - SiteId = info.SiteId, - SubjectId = info.SubjectId, - SubjectVisitId = subjectVisitId, - Identification = "Edit|Visit|Status|Visit-Image Forward" - }; + + var targetPath = "/IMPORT-IMAGES/" + info.TrialCode + "_" + info.SubjectCode + "_" + info.VisitName; var path = _dicomFileStoreHelper.GetSubjectVisitPath(info.TrialId, info.SiteId, info.SubjectId, info.SubjectVisitId); @@ -1953,26 +1889,22 @@ namespace IRaCIS.Core.Application.Image.QA u => new SubjectVisit() { ForwardState = ForwardStateEnum.Forwarded, ForwardUserId = _userInfo.Id, ForwardTime = DateTime.Now }); isSuccess = true; - keyValuePairs["ForwardState"] = ForwardStateEnum.Forwarded; + } catch (Exception e) { await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { ForwardState = ForwardStateEnum.ForwardFailed }); - keyValuePairs["ForwardState"] = ForwardStateEnum.ForwardFailed; + return ResponseOutput.NotOk("转发失败 " + e.Message); } - - data.JsonDetail = JsonConvert.SerializeObject(keyValuePairs); - datas.Add(data); } - // 这里使用的是批量更新 - await _subjectVisitRepository.AddListInspectionRecordAsync(datas); + await _subjectVisitRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs index 63b77b62f..a9c1b57d4 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs @@ -86,8 +86,8 @@ namespace IRaCIS.Core.Application.Triggers JsonDetail = subjectvisit.ToJcJson(), }); - // 这里是触发器的位置 - await _subjectVisitRepository.AddListInspectionRecordAsync(datas); + //// 这里是触发器的位置 + //await _subjectVisitRepository.AddListInspectionRecordAsync(datas); await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SVENDTC = null, SVSTDTC = null, SubmitState = SubmitStateEnum.None }); diff --git a/IRaCIS.Core.Application/_MediatR/Handlers/ConsistencyVerificationHandler.cs b/IRaCIS.Core.Application/_MediatR/Handlers/ConsistencyVerificationHandler.cs index af2b6a39b..4c0766c01 100644 --- a/IRaCIS.Core.Application/_MediatR/Handlers/ConsistencyVerificationHandler.cs +++ b/IRaCIS.Core.Application/_MediatR/Handlers/ConsistencyVerificationHandler.cs @@ -93,8 +93,7 @@ namespace IRaCIS.Core.Application.MediatR.Handlers var svGroup = dbList.GroupBy(t => new { t.SubjectVisitId, t.SiteCode, t.SubjectCode, t.VisitName }) .Select(g => new { g.Key.SubjectCode, g.Key.VisitName, g.Key.SiteCode, g.Key.SubjectVisitId, StudyList = g.ToList() }).ToList(); - List datas = new List(); - var createtime = DateTime.Now; + foreach (var sv in svGroup) { @@ -134,51 +133,10 @@ namespace IRaCIS.Core.Application.MediatR.Handlers dbSV.CheckResult = "根据导入的一致性核查数据,请确认本访视以下不一致检查项信息:" + String.Join(" | ", dbExceptExcel.Select(t => $"EDC 缺少:{t.StudyDate} {t.Modality} ")) + " | " + String.Join(" | ", excelExceptDB.Select(t => $"IRC 缺少:{t.StudyDate} {t.Modality}")); //新增一致性核查质疑记录 - datas.Add(new DataInspection() - { - - SiteId = dbSV.SiteId, - SubjectId = dbSV.SubjectId, - TrialId = dbSV.TrialId, - SubjectVisitId = dbSV.Id, - CreateTime = createtime.AddMilliseconds(200), - Identification = "Add|Consistency Check Query|Data|Visit-Consistency Check", - JsonDetail = JsonConvert.SerializeObject(new - { - SubmitState = dbSV.SubmitState, - AuditState = dbSV.AuditState, - CheckState = dbSV.CheckState, - CheckResult= dbSV.CheckResult, - TalkContent= dbSV.CheckResult, - RequestBackState= dbSV.RequestBackState, - CheckChallengeState = dbSV.CheckChallengeState, - - }) - }); + - datas.Add(new DataInspection() - { - - SiteId = dbSV.SiteId, - SubjectId = dbSV.SubjectId, - TrialId = dbSV.TrialId, - SubjectVisitId = dbSV.Id, - CreateTime = createtime.AddMilliseconds(500), - Identification = "Edit|Consistency Check Query|Data|Visit-Consistency Check|Send", - JsonDetail = JsonConvert.SerializeObject(new - { - SubmitState = dbSV.SubmitState, - AuditState = dbSV.AuditState, - CheckState = dbSV.CheckState, - CheckResult = dbSV.CheckResult, - TalkContent = dbSV.CheckResult, - RequestBackState = dbSV.RequestBackState, - CheckChallengeState = dbSV.CheckChallengeState, - - }) - }); dbSV.CheckState = CheckStateEnum.CVIng; @@ -191,25 +149,6 @@ namespace IRaCIS.Core.Application.MediatR.Handlers } dbSV.CheckTime = DateTime.Now; - // 在线一致性核查 - datas.Add(new DataInspection() - { - - SiteId = dbSV.SiteId, - SubjectId = dbSV.SubjectId, - TrialId = dbSV.TrialId, - SubjectVisitId = dbSV.Id, - CreateTime= createtime, - Reason= dbSV.ManualPassReason, - Identification = "Add|Visit|Status|Visit-Consistency Check", - JsonDetail = JsonConvert.SerializeObject(new - { - SubmitState = dbSV.SubmitState, - AuditState= dbSV.AuditState, - CheckState = dbSV.CheckState, - - }) - }); await _subjectVisitRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 19de989c5..1723c8def 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -73,7 +73,22 @@ namespace IRaCIS.Core.Infra.EFCore.Common #endregion #region 区分 - + + // 项目 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial))) + { + await InsertInspection(item, type, x => new DataInspection() + { + TrialId = x.Id, + TrialName = x.ExperimentName, + }); + } + + // TrialDocument + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocument))) + { + await InsertInspection(item, type); + } // 项目人员 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser))) @@ -87,10 +102,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common { SubjectId = x.Id, SubjectCode=x.Code, - },new - { - test="受试者" - }); } // 访视 @@ -109,30 +120,100 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 访视计划 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage))) { - await InsertInspection(item, type, x => new DataInspection() + await InsertInspection(item, type, x => new DataInspection() { VisitStageId = x.Id, }); } - // 检查 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) + + // 既往手术史 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousSurgery))) { - await InsertInspection(item, type, x => new DataInspection() + await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, }); } + // 既往放疗史 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousHistory))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } - //foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) - //{ - // await InsertInspection(item, type, x => new DataInspection() - // { - // GeneralId = x.Id, - // }); - //} + // 其他治疗史 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousOther))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } + + // 检查 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } + + // 序列 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomSeries))) + { + var entity = item.Entity as DicomSeries; + + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + },new { + StudyCode = entity.DicomStudy.StudyCode, + Modalities = entity.DicomStudy.Modalities, + }); + } + + //质疑 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } + + //一致性核查 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } + + //Qc 问题 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } + + + //Qc 问题答案 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } #endregion }