diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index b6d1b5917..9b9110fad 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -357,21 +357,6 @@ 添加签名记录 /// - - - 添加稽查记录 - - 添加对象 - 签名Id - - - - - 批量添加稽查记录 - - - - 往json里面添加属性 diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index fd5450d3c..846e4cc74 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -230,12 +230,6 @@ namespace IRaCIS.Core.Application.Service.Inspection var signSuccess = await _repository.BatchUpdateAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); } - //// 判断是否需要前面 - //if (AuditInfo.NeedSava) - //{ - // await AddInspectionRecordAsync(AuditInfo, signId); - //} - return bResult; } @@ -295,95 +289,9 @@ namespace IRaCIS.Core.Application.Service.Inspection } - /// - /// 添加稽查记录 - /// - /// 添加对象 - /// 签名Id - /// - public async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null) - { - if (addDto == new DataInspectionAddDTO()) - { - return ResponseOutput.Ok(); - } - //await SetEnum(addDto); - var add = _mapper.Map(addDto); - await SetInspectionNameValue(add); - Guid? parentId = null; - parentId = (await _repository.GetQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId && x.ChildrenType == add.ChildrenType && x.ObjectType == add.ObjectType && x.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; - add.ParentId = parentId; - - if (add.CreateTime == default(DateTime)) - { - add.CreateTime = DateTime.Now; - } - - add.CreateUserId = _userInfo.Id; - add.SignId = signId; - add.IP = _userInfo.IP; - - - add =await _dataInspectionRepository.SetDataInspectionDateType(add); - - - //await _repository.AddAsync(add); - - - //var success = await _repository.SaveChangesAsync(); - return ResponseOutput.Ok(); - - } - - /// - /// 批量添加稽查记录 - /// - /// - /// - public async Task AddListInspectionRecordAsync(List datas) - { - //var trialIds= datas.Select(x=>x.TrialId).Distinct().ToList(); - //var subjectVisitIds= datas.Select(x=>x.SubjectVisitId).Distinct().ToList(); - //var subjectIds = datas.Select(x => x.SubjectId).Distinct().ToList(); - //var siteIds = datas.Select(x => x.SiteId).Distinct().ToList(); - //var childrenTypes= datas.Select(x => x.ChildrenType).Distinct().ToList(); - //var objectTypes = datas.Select(x => x.ObjectType).Distinct().ToList(); - - - await _dataInspectionRepository.AddListInspectionRecordAsync(datas); - - await _dataInspectionRepository.SaveChangesAsync(); - - //foreach (var add in datas) - //{ - // await SetInspectionNameValue(add); - // add.ParentId = (await _repository.GetQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId && x.ChildrenType == add.ChildrenType && x.ObjectType == add.ObjectType&&x.VisitStageId==add.VisitStageId&& x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; - // add.CreateUserId = _userInfo.Id; - // add.IP = _userInfo.IP; - - - // var JsonData = JsonConvert.DeserializeObject>(add.JsonDetail); - - // foreach (var item in JsonData.Keys) - // { - // if (JsonData[item].ToString().ToLower() == "true".ToLower()) - // { - // JsonData[item] = "是"; - // } else if (JsonData[item].ToString().ToLower() == "false".ToLower()) - // { - // JsonData[item] = "否"; - // } - - // } - // add.JsonDetail= JsonConvert.SerializeObject(JsonData); - //} - - //await _dataInspectionRepository.AddRangeAsync(datas); - - } - + /// /// 往json里面添加属性 /// @@ -410,113 +318,7 @@ namespace IRaCIS.Core.Application.Service.Inspection } - ///// - ///// 处理枚举 - ///// - ///// - //public async Task SetEnum(DataInspectionAddDTO Data) - //{ - // //Data.JsonDetail= await _dataInspectionRepository.SetEnum(Data.TrialId.Value, Data.Identification, Data.JsonDetail); - // #region 枚举 - // //try - // //{ - // // var JsonData = JsonConvert.DeserializeObject>(Data.JsonDetail); - // // foreach (var item in Data.EnumList) - // // { - // // if (!JsonData.ContainsKey(item.Key)) - // // { - // // continue; - // // } - // // var value = JsonData[item.Key]; - // // if (value.GetType() == typeof(JArray)) - // // { - // // JArray arrays = (JArray)value; - // // if (item.Type.ToLower() == "id".ToLower()) - // // { - // // List guids = new List(); - // // arrays.ForEach(x => - // // { - // // guids.Add(Guid.Parse(x.ToString())); - // // }); - // // JsonData[item.Key] = string.Join(',', await _repository.GetQueryable().Where(x => guids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync()); - // // } - // // else if (item.Type.ToLower() == "ChildGroup".ToLower()) - // // { - // // List guids = new List(); - // // arrays.ForEach(x => - // // { - // // guids.Add(x.ToString()); - // // }); - // // JsonData[item.Key] = string.Join(',', await - // // _repository.GetQueryable().Where(x => x.Code == item.Code).GroupJoin( - // // _repository.GetQueryable().Where(x => guids.Contains(x.ChildGroup)), a => a.Id, b => b.ParentId, (a, b) => new - // // { - // // parent = b - // // }).SelectMany(a => a.parent, (m, n) => new - // // { - // // value = n.ValueCN - // // }).Select(x => x.value).ToListAsync() - // // ); - // // } - // // else - // // { - // // List guids =new List(); - // // arrays.ForEach(x => - // // { - // // guids.Add(x.ToString()); - // // }); - // // JsonData[item.Key] = string.Join(',', await - // // _repository.GetQueryable().Where(x => x.Code == item.Code).GroupJoin( - // // _repository.GetQueryable().Where(x=>guids.Contains(x.Code)), a => a.Id, b => b.ParentId, (a, b) => new - // // { - // // parent = b - // // }).SelectMany(a => a.parent, (m, n) => new - // // { - // // value = n.ValueCN - // // }).Select(x => x.value).ToListAsync() - // // ); - // // } - // // } - // // else - // // { - // // if (item.Type.ToLower() == "id".ToLower()) - // // { - // // Guid guid = Guid.Parse(value.ToString()); - // // JsonData[item.Key] = await _repository.GetQueryable().Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync(); - // // } - // // else if (item.Type.ToLower() == "ChildGroup".ToLower()) - // // { - // // JsonData[item.Key] = await _repository.GetQueryable().Where(x => x.Code == item.Code).Join(_repository.GetQueryable().Where(x => x.ChildGroup == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new - // // { - // // value = b.ValueCN - // // }).Select(x => x.value).FirstOrDefaultAsync(); - // // } - // // else - // // { - // // JsonData[item.Key] = await _repository.GetQueryable().Where(x=>x.Code==item.Code).Join(_repository.GetQueryable().Where(x=>x.Code== value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new - // // { - // // value=b.ValueCN - // // }).Select(x=>x.value).FirstOrDefaultAsync(); - - // // } - // // } - // // } - - - - // // Data.JsonDetail = JsonConvert.SerializeObject(JsonData); - - // //} - // //catch (Exception) - // //{ - - // // throw new BusinessValidationFailedException("Json 对象枚举异常"); - // //} - - - - // #endregion - //} + /// @@ -526,96 +328,8 @@ namespace IRaCIS.Core.Application.Service.Inspection /// public async Task SetInspectionNameValue(DataInspection Data) { - await _dataInspectionRepository.SetInspectionNameValue(Data); - //#region 项目名称 - - //var trialdata = await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == Data.TrialId); - //Data.ResearchProgramNo = trialdata?.ResearchProgramNo; - //if (Data.TrialName.IsNullOrEmpty()) - //{ - // Data.TrialName = trialdata?.ExperimentName; - //} - //#endregion - - //#region 测试中心名称 - - - //Data.SiteCode = (await _repository.GetQueryable().FirstOrDefaultAsync(x => x.TrialId == Data.TrialId && x.SiteId == Data.SiteId))?.TrialSiteCode; - - //var sitedata = await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == Data.SiteId); - - //if (Data.SiteName.IsNullOrEmpty()) - //{ - // Data.SiteName = sitedata?.SiteName; - //} - //#endregion - - //#region 受试者 - - - //if (Data.SubjectCode.IsNullOrEmpty()) - //{ - - // Data.SubjectCode = (await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == Data.SubjectId))?.Code; - //} - //#endregion - - //#region 访视 - //if (Data.SubjectVisitName.IsNullOrEmpty()) - //{ - // Data.SubjectVisitName = (await _repository.GetQueryable().FirstOrDefaultAsync(x => x.Id == Data.SubjectVisitId))?.VisitName; - //} - //#endregion - - //#region 创建者 - //if (Data.CreateUserName.IsNullOrEmpty() || Data.RoleName.IsNullOrEmpty()) - //{ - // var userdata = await _repository.GetQueryable().Where(x => x.Id == Data.CreateUserId).GroupJoin(_repository.GetQueryable(), a => a.UserTypeId, b => b.Id, (a, b) => new - // { - // UserName = a.FirstName + a.LastName, - // Role = b - // }).SelectMany(a => a.Role, (m, n) => new - // { - // UserName = m.UserName, - // RoleName = n.UserTypeShortName - // }).FirstOrDefaultAsync(); - - // if (userdata != null) - // { - // if (Data.CreateUserName.IsNullOrEmpty()) - // { - // Data.CreateUserName = userdata?.UserName; - // } - - - // if (Data.RoleName.IsNullOrEmpty()) - // { - // Data.RoleName = userdata?.RoleName; - // } - // } - //} - //#endregion - - //#region 取操作类型 - //try - //{ - // var from = await _frontAuditConfigRepository.FirstOrDefaultAsync(x => x.Identification == Data.Identification); - // Data.ObjectType = from.ObjectTypeId; - // Data.OptType = from.OptTypeId; - // Data.ChildrenType = from.ChildrenTypeId; - // Data.ModuleType = from.ModuleTypeId; - //} - //catch (Exception) - //{ - - // throw new BusinessValidationFailedException("操作标识异常"); - //} - - - //#endregion - } diff --git a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs index 184c9c751..ef2b3612e 100644 --- a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs @@ -23,16 +23,6 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface Task RecordSing(SignDTO SignInfo); Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null); - //Task SetEnum(DataInspectionAddDTO Data); - - - Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null); - - /// - /// 批量添加稽查记录 - /// - /// - /// - //Task AddListInspectionRecordAsync(List datas); + } } diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index c046e7e3e..294b6a802 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -356,13 +356,6 @@ namespace IRaCIS.Core.Application.Contracts { var file = this._httpContext.HttpContext?.Request.Form; var result = await UploadNoneDicomFile(file, fileDto.subjectVisitId, fileDto.noneDicomStudyId); - if (result.IsSuccess) - { - var data = JsonConvert.DeserializeObject(fileDto.AuditInfo); - data.GeneralId = fileDto.noneDicomStudyId; - await _inspectionService.AddInspectionRecordAsync(data); - } - return result; } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs index e89fe7329..ce580b926 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs @@ -28,14 +28,6 @@ namespace IRaCIS.Core.Infra.EFCore /// Task SetInspectionNameValue(DataInspection Data); - /// - /// 添加稽查记录 - /// - /// - /// - Task AddListInspectionRecordAsync(List datas); - - /// /// 格式化日期和时间 /// diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 8f0681103..75032fd0d 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -860,7 +860,7 @@ namespace IRaCIS.Core.Infra.EFCore catch (Exception) { - //throw new BusinessValidationFailedException("Json 对象枚举异常"); + } } @@ -873,266 +873,9 @@ namespace IRaCIS.Core.Infra.EFCore } - /// - /// 添加稽查记录 - /// - /// 实体 - /// 是否保存 - /// - private async Task AddInspectionAsync(TEntity entity, bool isSaveAudit = false) - { - bool needsave = true; - DataInspection inspectionData = new DataInspection() - { - Identification = $"{GetRequestUrl()}/{ typeof(TEntity).ToString().Substring(typeof(TEntity).ToString().LastIndexOf('.') + 1)}/Add", - }; + - MapData(entity, inspectionData); - - var createtime = DateTime.Now; - // 项目 - if (typeof(TEntity) == typeof(Trial)) - { - Trial data = entity as Trial; - inspectionData = new DataInspection() - { - TrialId = data.Id, - SubjectId = data.Id, - TrialName = data.ExperimentName, - ResearchProgramNo = data.ResearchProgramNo, - IsSign = false, - CreateTime = createtime, - Identification = "Init|Trial|Status|Trial Setting-Infomation", // 初始化项目 - JsonDetail = entity.ToJcJson() - }; - } - // 项目人员 - else if (typeof(TEntity) == typeof(TrialUser)) - { - - } - // 受试者 - else if (typeof(TEntity) == typeof(Subject)) - { - Subject data = entity as Subject; - inspectionData = new DataInspection() - { - TrialId = data.TrialId, - SiteId = data.SiteId, - SubjectId = data.Id, - SubjectCode = data.Code, - IsSign = false, - CreateTime = createtime, - Identification = "Init|Subject|Status|Subject", // 初始化受试者信息 - JsonDetail = entity.ToJcJson() - }; - } - - // Dicom序列 // 移动不进来 - //if (typeof(TEntity) == typeof(DicomSeries)) - //{ - // DicomSeries dicomStudy = entity as DicomSeries; - // datas.Add(new DataInspection() - // { - - // SiteId = dicomStudy.SiteId, - // SubjectId = dicomStudy.SubjectId, - // TrialId = dicomStudy.TrialId, - // GeneralId = dicomStudy.StudyId, - // 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, - - // }) - // }); - //} - // 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(NoneDicomStudyFile)) - { - NoneDicomStudyFile data = entity as NoneDicomStudyFile; - var subjectVisitId = await _dbContext.NoneDicomStudy.Where(x => x.Id == data.NoneDicomStudyId).Select(x => x.SubjectVisitId).FirstOrDefaultAsync(); - await UpdateSubjectVisit(subjectVisitId, SubmitStateEnum.ToSubmit, "上传非Dicom影像"); - } - else - { - needsave = false; - } - - // 修改访视状态记录稽查 - 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; - - inspectionData = 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, - CreateTime = createtime.AddMilliseconds(100), - JsonDetail = subjectvisit.ToJcJson(), - }; - } - - } - - - if (needsave) - { - await AddInspectionRecordAsync(inspectionData, entity); - } - - } - - - - /// - /// 获取URl参数 - /// - /// - private string GetRequestUrl() - { - return _userInfo.RequestUrl; - } - - /// - /// 映射数据 - /// - /// - /// 要赋值的对象 - private void MapData(dynamic data, dynamic mapData) - { - List column = new List() { "TrialId", "SiteId", "SubjectId", "SubjectVisitId", "CreateUserName", "TrialName", "SiteName", "SubjectCode", "SubjectVisitName", "RoleName", "SiteCode", "ResearchProgramNo" }; - foreach (var item in column) - { - try - { - var i = mapData.GetType().GetProperty(item).GetValue(mapData); - if (i == null) - { - var value = data.GetType().GetProperty(item).GetValue(data); - mapData.GetType().GetProperty(item).SetValue(mapData, value); - } - - } - catch (Exception) - { - continue; - - } - } - } - - - /// - /// 添加稽查记录 - /// - /// 稽查数据 - /// 实体信息 - /// - public async Task AddInspectionRecordAsync(DataInspection add, dynamic data) - { - InspectionGeneralData generalData = new InspectionGeneralData(); - MapData(add, generalData); - await SetInspectionNameValue(generalData); - #region 处理标识 - try - { - var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == add.Identification); - add.ObjectType = from?.ObjectTypeId; - add.OptType = from?.OptTypeId; - add.ChildrenType = from?.ChildrenTypeId; - add.ModuleType = from?.ModuleTypeId; - } - catch (Exception) - { - - throw new BusinessValidationFailedException("操作标识异常"); - } - #endregion - if (add.ParentId == null) - { - add.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId && x.ChildrenType == add.ChildrenType && x.ObjectType == add.ObjectType && x.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; - - } - add.CreateUserId = _userInfo.Id; - add.IP = _userInfo.IP; - if (add.CreateTime == default(DateTime)) - { - add.CreateTime = DateTime.Now; - } - var inspectionData = new InspectionData() - { - Data = data, - Inspection = generalData - }; - - add.JsonDetail = inspectionData.ToJcJson(); - await SetDataInspectionDateType(add); - - await _dbContext.DataInspection.AddAsync(add); - } - - - - /// - /// 添加稽查记录 - /// - /// - /// - public async Task AddListInspectionRecordAsync(List datas) - { - - //var trialIds= datas.Select(x=>x.TrialId).Distinct().ToList(); - //var subjectVisitIds= datas.Select(x=>x.SubjectVisitId).Distinct().ToList(); - //var subjectIds = datas.Select(x => x.SubjectId).Distinct().ToList(); - //var siteIds = datas.Select(x => x.SiteId).Distinct().ToList(); - //var childrenTypes= datas.Select(x => x.ChildrenType).Distinct().ToList(); - //var objectTypes = datas.Select(x => x.ObjectType).Distinct().ToList(); - - foreach (var add in datas) - { - await SetInspectionNameValue(add); - if (add.ParentId == null) - { - add.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId && x.ChildrenType == add.ChildrenType && x.ObjectType == add.ObjectType && x.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; - - } - add.CreateUserId = _userInfo.Id; - add.IP = _userInfo.IP; - if (add.CreateTime == default(DateTime)) - { - add.CreateTime = DateTime.Now; - } - //add.JsonDetail = await SetEnum(add.TrialId, add.Identification, add.JsonDetail); - await SetDataInspectionDateType(add); - } - - //await _dbContext.DataInspection.AddRangeAsync(datas); - - } - /// /// 格式化日期和时间 /// @@ -1196,9 +939,6 @@ namespace IRaCIS.Core.Infra.EFCore } } - - - /// /// 设置项目以及名称 /// @@ -1313,75 +1053,7 @@ namespace IRaCIS.Core.Infra.EFCore } - /// - /// 设置项目以及名称 - /// - /// - /// - public async Task SetInspectionNameValue(InspectionGeneralData Data) - { - #region 项目名称 - var trialdata = await _dbContext.Trial.Select(x => new { x.Id, x.ResearchProgramNo, x.ExperimentName, }).FirstOrDefaultAsync(x => x.Id == Data.TrialId); - if (IsNullOrEmpty(Data.ResearchProgramNo)) - { - - Data.ResearchProgramNo = trialdata?.ResearchProgramNo; - } - - if (IsNullOrEmpty(Data.TrialName)) - { - Data.TrialName = trialdata?.ExperimentName; - } - #endregion - - #region 测试中心名称 - - - Data.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.TrialId == Data.TrialId && x.SiteId == Data.SiteId))?.TrialSiteCode; - - - - if (IsNullOrEmpty(Data.SiteName) && Data.SiteId != null) - { - var sitedata = await _dbContext.Site.Where(x => x.Id == Data.SiteId).Select(x => new { x.SiteName }).FirstOrDefaultAsync(); - Data.SiteName = sitedata?.SiteName; - } - #endregion - - #region 受试者 - - - if (IsNullOrEmpty(Data.SubjectCode) && Data.SubjectId != null) - { - - Data.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == Data.SubjectId).Select(x => new { x.Code }).FirstOrDefaultAsync())?.Code; - } - #endregion - - #region 访视 - if (IsNullOrEmpty(Data.SubjectVisitName)) - { - Data.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == Data.SubjectVisitId).Select(x => new { x.VisitName }).FirstOrDefaultAsync())?.VisitName; - } - #endregion - - #region 创建者 - - if (IsNullOrEmpty(Data.CreateUserName)) - { - Data.CreateUserName = _userInfo.RealName; - } - - if (IsNullOrEmpty(Data.RoleName)) - { - Data.RoleName = _userInfo.UserTypeShortName; - } - #endregion - - - - } #endregion