Uat_Study
he 2022-05-23 17:49:16 +08:00
parent 13ef3e69b9
commit ffa87ed1c3
6 changed files with 5 additions and 659 deletions

View File

@ -357,21 +357,6 @@
<member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.AddSignRecordAsync(IRaCIS.Core.Application.Contracts.SignDTO)">
<summary> 添加签名记录 </summary> ///
</member>
<member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.AddInspectionRecordAsync(IRaCIS.Core.Application.Service.Inspection.DTO.DataInspectionAddDTO,System.Nullable{System.Guid})">
<summary>
添加稽查记录
</summary>
<param name="addDto">添加对象</param>
<param name="signId">签名Id</param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.AddListInspectionRecordAsync(System.Collections.Generic.List{IRaCIS.Core.Domain.Models.DataInspection})">
<summary>
批量添加稽查记录
</summary>
<param name="datas"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.AddJsonItem(System.String,System.Collections.Generic.Dictionary{System.String,System.Object})">
<summary>
往json里面添加属性

View File

@ -230,12 +230,6 @@ namespace IRaCIS.Core.Application.Service.Inspection
var signSuccess = await _repository.BatchUpdateAsync<TrialSign>(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
}
/// <summary>
/// 添加稽查记录
/// </summary>
/// <param name="addDto">添加对象</param>
/// <param name="signId">签名Id</param>
/// <returns></returns>
public async Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null)
{
if (addDto == new DataInspectionAddDTO())
{
return ResponseOutput.Ok();
}
//await SetEnum(addDto);
var add = _mapper.Map<DataInspection>(addDto);
await SetInspectionNameValue(add);
Guid? parentId = null;
parentId = (await _repository.GetQueryable<DataInspection>().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();
}
/// <summary>
/// 批量添加稽查记录
/// </summary>
/// <param name="datas"></param>
/// <returns></returns>
public async Task AddListInspectionRecordAsync(List<DataInspection> 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<DataInspection>().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<IDictionary<string, object>>(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);
}
/// <summary>
/// 往json里面添加属性
/// </summary>
@ -410,113 +318,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
}
///// <summary>
///// 处理枚举
///// </summary>
///// <returns></returns>
//public async Task SetEnum(DataInspectionAddDTO Data)
//{
// //Data.JsonDetail= await _dataInspectionRepository.SetEnum(Data.TrialId.Value, Data.Identification, Data.JsonDetail);
// #region 枚举
// //try
// //{
// // var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(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<Guid> guids = new List<Guid>();
// // arrays.ForEach(x =>
// // {
// // guids.Add(Guid.Parse(x.ToString()));
// // });
// // JsonData[item.Key] = string.Join(',', await _repository.GetQueryable<Dictionary>().Where(x => guids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync());
// // }
// // else if (item.Type.ToLower() == "ChildGroup".ToLower())
// // {
// // List<string> guids = new List<string>();
// // arrays.ForEach(x =>
// // {
// // guids.Add(x.ToString());
// // });
// // JsonData[item.Key] = string.Join(',', await
// // _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
// // _repository.GetQueryable<Dictionary>().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<string> guids =new List<string>();
// // arrays.ForEach(x =>
// // {
// // guids.Add(x.ToString());
// // });
// // JsonData[item.Key] = string.Join(',', await
// // _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
// // _repository.GetQueryable<Dictionary>().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<Dictionary>().Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync();
// // }
// // else if (item.Type.ToLower() == "ChildGroup".ToLower())
// // {
// // JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).Join(_repository.GetQueryable<Dictionary>().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<Dictionary>().Where(x=>x.Code==item.Code).Join(_repository.GetQueryable<Dictionary>().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
//}
/// <summary>
@ -526,96 +328,8 @@ namespace IRaCIS.Core.Application.Service.Inspection
/// <returns></returns>
public async Task SetInspectionNameValue(DataInspection Data)
{
await _dataInspectionRepository.SetInspectionNameValue(Data);
//#region 项目名称
//var trialdata = await _repository.GetQueryable<Trial>().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<TrialSite>().FirstOrDefaultAsync(x => x.TrialId == Data.TrialId && x.SiteId == Data.SiteId))?.TrialSiteCode;
//var sitedata = await _repository.GetQueryable<Site>().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<Subject>().FirstOrDefaultAsync(x => x.Id == Data.SubjectId))?.Code;
//}
//#endregion
//#region 访视
//if (Data.SubjectVisitName.IsNullOrEmpty())
//{
// Data.SubjectVisitName = (await _repository.GetQueryable<SubjectVisit>().FirstOrDefaultAsync(x => x.Id == Data.SubjectVisitId))?.VisitName;
//}
//#endregion
//#region 创建者
//if (Data.CreateUserName.IsNullOrEmpty() || Data.RoleName.IsNullOrEmpty())
//{
// var userdata = await _repository.GetQueryable<User>().Where(x => x.Id == Data.CreateUserId).GroupJoin(_repository.GetQueryable<UserType>(), 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
}

View File

@ -23,16 +23,6 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface
Task RecordSing(SignDTO SignInfo);
Task<dynamic> Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null);
//Task SetEnum(DataInspectionAddDTO Data);
Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null);
/// <summary>
/// 批量添加稽查记录
/// </summary>
/// <param name="datas"></param>
/// <returns></returns>
//Task AddListInspectionRecordAsync(List<DataInspection> datas);
}
}

View File

@ -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<DataInspectionAddDTO>(fileDto.AuditInfo);
data.GeneralId = fileDto.noneDicomStudyId;
await _inspectionService.AddInspectionRecordAsync(data);
}
return result;
}

View File

@ -28,14 +28,6 @@ namespace IRaCIS.Core.Infra.EFCore
/// <returns></returns>
Task SetInspectionNameValue(DataInspection Data);
/// <summary>
/// 添加稽查记录
/// </summary>
/// <param name="datas"></param>
/// <returns></returns>
Task AddListInspectionRecordAsync(List<DataInspection> datas);
/// <summary>
/// 格式化日期和时间
/// </summary>

View File

@ -860,7 +860,7 @@ namespace IRaCIS.Core.Infra.EFCore
catch (Exception)
{
//throw new BusinessValidationFailedException("Json 对象枚举异常");
}
}
@ -873,266 +873,9 @@ namespace IRaCIS.Core.Infra.EFCore
}
/// <summary>
/// 添加稽查记录
/// </summary>
/// <param name="entity">实体</param>
/// <param name="isSaveAudit">是否保存</param>
/// <returns></returns>
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);
}
}
/// <summary>
/// 获取URl参数
/// </summary>
/// <returns></returns>
private string GetRequestUrl()
{
return _userInfo.RequestUrl;
}
/// <summary>
/// 映射数据
/// </summary>
/// <param name="data"></param>
/// <param name="mapData">要赋值的对象</param>
private void MapData(dynamic data, dynamic mapData)
{
List<string> column = new List<string>() { "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;
}
}
}
/// <summary>
/// 添加稽查记录
/// </summary>
/// <param name="add">稽查数据</param>
/// <param name="data">实体信息</param>
/// <returns></returns>
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);
}
/// <summary>
/// 添加稽查记录
/// </summary>
/// <param name="datas"></param>
/// <returns></returns>
public async Task AddListInspectionRecordAsync(List<DataInspection> 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);
}
/// <summary>
/// 格式化日期和时间
/// </summary>
@ -1196,9 +939,6 @@ namespace IRaCIS.Core.Infra.EFCore
}
}
/// <summary>
/// 设置项目以及名称
/// </summary>
@ -1313,75 +1053,7 @@ namespace IRaCIS.Core.Infra.EFCore
}
/// <summary>
/// 设置项目以及名称
/// </summary>
/// <param name="Data"></param>
/// <returns></returns>
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