diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index d5cf6cb72..404fb02b3 100644 --- a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs +++ b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs @@ -244,84 +244,14 @@ namespace IRaCIS.Application.Services await _trialRepository.UpdatePartialNowNoQueryAsync(trialId, t => new Trial() { VisitPlanConfirmed = true }); - //找到访视计划修改的Item - var changedList = await _visitStageRepository.Where(t => t.TrialId == trialId && t.IsConfirmed == false) - .Select(t => new - { - t.Trial.IsHaveFirstGiveMedicineDate, - t.Id, - t.VisitName, - t.TrialId, - t.VisitWindowLeft, - t.VisitWindowRight, - t.VisitDay, - t.VisitNum, - t.IsBaseLine, - t.BlindName, - t.Description, - IsConfirmed = true, - }).ToListAsync(); + - List datas = new List(); + - var createtime = DateTime.Now.AddSeconds(1); + - changedList.ForEach(x => - { - - datas.Add(new DataInspection() - { - IsSign = false, - - CreateTime = createtime, - //SubjectVisitName = x.VisitName, - VisitStageId = x.Id, - TrialId = x.TrialId, - JsonDetail = x.ToJcJson(), - Identification = "Confirm|Visit Plan Template|Data|Trial Setting-Visit Plan", - - }); - - }); - - - - - //foreach (var changedItem in changedList) - //{ - - // var list = await _subjectVisitRepository.Where(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id).ToListAsync(); - // list.ForEach(x => - // { - // datas.Add(new DataInspection() - // { - // BlindName = x.BlindName, - // IsSign = false, - // SiteId = x.SiteId, - // SubjectId = x.SubjectId, - // SubjectVisitId = x.Id, - // CreateTime = createtime, - // SubjectVisitName = x.VisitName, - // TrialId = x.TrialId, - // Reason = "确认访视修改状态", - // JsonDetail = JsonConvert.SerializeObject(new - // { - // IsBaseLine = changedItem.IsBaseLine, - // VisitName = changedItem.VisitName, - // VisitNum = changedItem.VisitNum, - // VisitDay = changedItem.VisitDay, - // SubmitState = x.SubmitState, - // VisitWindowLeft = changedItem.VisitWindowLeft, - // VisitWindowRight = changedItem.VisitWindowRight - // }), - // Identification = "Edit|Visit|Info|Visit-Image Upload" - // }); - // }); - - //} - var subjectsids = _repository.GetQueryable().Where(x => x.TrialId == trialId).Select(x => new { x.Code, @@ -341,7 +271,28 @@ namespace IRaCIS.Application.Services var addvisitStages = await _visitStageRepository.Where(x => !x.IsHaveFirstConfirmed && x.TrialId == trialId).ToListAsync(); - + addvisitStages.ForEach(x => + { + subjectsids.ForEach(y => + { + Guid guid = NewId.NextGuid(); + SubjectVisit subjectVisit = new SubjectVisit() + { + SiteId = y.SiteId, + SubjectId = y.Id, + Id = guid, + VisitName = x.VisitName, + + BlindName = x.BlindName, + IsBaseLine = x.IsBaseLine, + IsUrgent = false, + }; + subjectVisits.Add(subjectVisit); + + }); + + + }); //await _subjectVisitRepository.AddRangeAsync() await _repository.AddRangeAsync(subjectVisits); diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 0d2c82813..19de989c5 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -73,8 +73,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common #endregion #region 区分 - - + // 项目人员 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser))) @@ -88,9 +87,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common { SubjectId = x.Id, SubjectCode=x.Code, + },new + { + test="受试者" + }); } - // 访视 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) { @@ -103,20 +105,36 @@ namespace IRaCIS.Core.Infra.EFCore.Common SubjectVisitName=x.VisitName, }); } - #endregion + + // 访视计划 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage))) + { + await InsertInspection(item, type, x => new DataInspection() + { + VisitStageId = x.Id, + }); + } + + // 检查 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } - - - // 插入稽查信息 - //async Task InsertInspectionData(Expression> expression = null) + //foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) //{ - // await InsertInspection(item, type, x => new DataInspection() + // await InsertInspection(item, type, x => new DataInspection() // { - // GeneralId = x.Id + // GeneralId = x.Id, // }); //} + #endregion + } /// @@ -127,7 +145,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// 类型 /// 表达式 /// - public async Task InsertInspection(EntityEntry data, string type, Expression> expression = null) where T:class + public async Task InsertInspection(EntityEntry data, string type, Expression> expression = null,object otherItem=null) where T:class { DataInspection inspection = new DataInspection(); @@ -144,7 +162,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common inspection.LastJsonDetail = originaldata.ToJcJson(); } - await AddInspectionRecordAsync(inspection, data.Entity); + await AddInspectionRecordAsync(inspection, data.Entity, otherItem); } @@ -195,7 +213,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// 数据 /// /// - public async Task AddInspectionRecordAsync(DataInspection add, dynamic data) + public async Task AddInspectionRecordAsync(DataInspection add, dynamic data,object otherItem=null) { MapData(data, add); InspectionGeneralData generalData = new InspectionGeneralData(); @@ -233,9 +251,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common add.SignId = _userInfo.SignId; add.IsSign = true; } + var inspectionData = new InspectionData() { - Data = data, + Data = AddJsonItem(data,otherItem), Inspection = generalData }; add.JsonDetail = inspectionData.ToJcJson(); @@ -244,6 +263,41 @@ namespace IRaCIS.Core.Infra.EFCore.Common } + + /// + /// 往json里面添加属性 + /// + /// json + /// 字典 + /// + public IDictionary AddJsonItem(dynamic json, object otherItem=null) + { + + + var JsonData = JsonConvert.DeserializeObject>((json as object).ToJcJson()); + + if (otherItem == null) + { + return JsonData; + } + var other = JsonConvert.DeserializeObject>(otherItem.ToJcJson()); + + foreach (var item in other) + { + if (JsonData.ContainsKey(item.Key)) + { + JsonData[item.Key] = item.Value; + } + else + { + JsonData.Add(item.Key, item.Value); + } + + } + return JsonData; + + } + /// /// 判断是否为空 ///