修改一版

Uat_Study
he 2022-05-25 13:29:50 +08:00
parent fe7be9b169
commit d0b617b5d6
1 changed files with 112 additions and 93 deletions

View File

@ -95,7 +95,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#region 所有
//foreach (var item in entitys)
//{
// await InsertInspection<TrialUser>(item, type);
// await InsertInspection<TrialUser>(item.Entity, type);
//}
#endregion
@ -114,7 +114,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList();
var usertypeNames = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync();
var usertypeName = string.Join(",", usertypeNames);
await InsertInspection<SystemDocument>(item, type, x => new DataInspection()
await InsertInspection<SystemDocument>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id
}, new
@ -126,9 +126,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 签名模板
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemBasicData)))
{
var entity = item.Entity as SystemBasicData;
type = type + (entity.ParentId == null ? "/parent" : string.Empty);
await InsertInspection<SystemBasicData>(item, type, x => new DataInspection()
await InsertInspection<SystemBasicData>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
});
@ -137,20 +135,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial)))
{
var originalValues = item.OriginalValues.ToObject() as Trial;
switch (GetRequestUrl().ToLower())
{
case "configtrialbasicinfo/configtrialbasicinfoconfirm":
type = type + "/" + originalValues.IsTrialBasicLogicConfirmed.ToString();
break;
case "configtrialbasicinfo/configtrialprocessinfoconfirm":
type = type + "/" + originalValues.IsTrialProcessConfirmed.ToString();
break;
case "configtrialbasicinfo/configtrialurgentinfoconfirm":
type = type + "/" + originalValues.IsTrialUrgentConfirmed.ToString();
break;
}
var entity = item.Entity as Trial;
List<string> trials = new List<string>();
var trialids = new List<Guid>();
@ -167,7 +152,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
trials = await this._dbContext.Dictionary.Where(x => trialids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync();
await InsertInspection<Trial>(item, type, x => new DataInspection()
await InsertInspection<Trial>(item.Entity, type, x => new DataInspection()
{
TrialId = x.Id,
@ -191,7 +176,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
VisitPlanStatus = false;
}
await InsertInspection<VisitStage>(item, type, x => new DataInspection()
await InsertInspection<VisitStage>(item.Entity, type, x => new DataInspection()
{
VisitStageId = x.Id,
GeneralId = x.Id,
@ -215,7 +200,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList();
var usertypeNames = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync();
var usertypeName = string.Join(",", usertypeNames);
await InsertInspection<TrialDocument>(item, type, x => new DataInspection()
await InsertInspection<TrialDocument>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id
}, new
@ -231,7 +216,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
var entity = item.Entity as SystemDocConfirmedUser;
var systemDocument = await _dbContext.SystemDocument.Where(x => x.Id == entity.SystemDocumentId).FirstOrDefaultAsync();
await InsertInspection<SystemDocConfirmedUser>(item, type, x => new DataInspection()
await InsertInspection<SystemDocConfirmedUser>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
}, new
@ -241,7 +226,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
Name = systemDocument.Name,
CreateTime = systemDocument.CreateTime,
IsSigned = "是",// 是否签署 添加了就是签署了
}, null);
});
}
// 项目文件签署
@ -251,7 +236,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var trialDocument = await _dbContext.TrialDocument.Where(x => x.Id == entity.TrialDocumentId).FirstOrDefaultAsync();
var trialid = trialDocument.TrialId;
await InsertInspection<TrialDocUserTypeConfirmedUser>(item, type, x => new DataInspection()
await InsertInspection<TrialDocUserTypeConfirmedUser>(item.Entity, type, x => new DataInspection()
{
TrialId = trialid,
GeneralId = x.Id,
@ -261,13 +246,13 @@ namespace IRaCIS.Core.Infra.EFCore.Common
Name = trialDocument.Name,
CreateTime = trialDocument.CreateTime,
IsSigned = "是",// 是否签署 添加了就是签署了
}, null);
});
}
// 医生
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll)))
{
await InsertInspection<Enroll>(item, type, x => new DataInspection()
await InsertInspection<Enroll>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
});
@ -276,7 +261,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 医生详情
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(EnrollDetail)))
{
await InsertInspection<EnrollDetail>(item, type, x => new DataInspection()
await InsertInspection<EnrollDetail>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
});
@ -290,7 +275,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
entity.Site = await _dbContext.Site.Where(x => x.Id == entity.SiteId).FirstOrDefaultAsync();
}
await InsertInspection<TrialSite>(item, type, x => new DataInspection()
await InsertInspection<TrialSite>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
@ -311,7 +296,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as TrialUser;
var user = await _dbContext.Users.Include(x => x.UserTypeRole).FirstOrDefaultAsync(x => x.Id == entity.UserId);
await InsertInspection<TrialUser>(item, type, x => new DataInspection
await InsertInspection<TrialUser>(item.Entity, type, x => new DataInspection
{
TrialId = x.TrialId,
}, new
@ -358,7 +343,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
UserType userType = new UserType();
userType = await _dbContext.UserType.Where(x => x.Id == user.UserTypeId).FirstOrDefaultAsync();
await InsertInspection<TrialSiteUser>(item, type, x => new DataInspection()
await InsertInspection<TrialSiteUser>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
}, new
@ -398,7 +383,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
entity.ReviewerUser = await _dbContext.User.Where(x => x.Id == entity.ReviewerUserId).FirstOrDefaultAsync();
}
await InsertInspection<TrialSiteSurvey>(item, type, x => new DataInspection()
await InsertInspection<TrialSiteSurvey>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
@ -420,7 +405,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
var entity = item.Entity as TrialQCQuestion;
var paretName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync();
await InsertInspection<TrialQCQuestion>(item, type, x => new DataInspection()
await InsertInspection<TrialQCQuestion>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
}, new
@ -443,7 +428,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as Subject;
var FinalSubjectVisitName = await _dbContext.SubjectVisit.AsNoTracking().Where(x => x.Id == entity.FinalSubjectVisitId && entity.FinalSubjectVisitId != null).Select(x => x.VisitName).FirstOrDefaultAsync();
await InsertInspection<Subject>(item, type, x => new DataInspection()
await InsertInspection<Subject>(item.Entity, type, x => new DataInspection()
{
SubjectId = x.Id,
SubjectCode = x.Code,
@ -456,7 +441,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 检查
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy)))
{
await InsertInspection<DicomStudy>(item, type, x => new DataInspection()
await InsertInspection<DicomStudy>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
});
@ -471,7 +456,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
dicomStudy = await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x => x.Id == entity.StudyId);
}
await InsertInspection<DicomSeries>(item, type, x => new DataInspection()
await InsertInspection<DicomSeries>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
}, new
@ -487,14 +472,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
var entity = item.Entity as NoneDicomStudy;
var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync();
switch (GetRequestUrl().ToLower())
{
case "nonedicomstudy/addorupdatenonedicomstudy":
type = _userInfo.UserTypeShortName + "/" + type;
break;
}
await InsertInspection<NoneDicomStudy>(item, type, x => new DataInspection()
await InsertInspection<NoneDicomStudy>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
}, new
@ -521,13 +501,13 @@ namespace IRaCIS.Core.Infra.EFCore.Common
filecount = filecount + count;
}
await InsertInspection(null, type, x => new DataInspection()
await InsertInspection<NoneDicomStudy>(noneDicomStudy, type, x => new DataInspection()
{
GeneralId = x.Id,
}, new
{
FileCount = filecount,
}, noneDicomStudy);
});
}
}
@ -553,7 +533,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// {
// fileCount = _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.NoneDicomStudyId).Count() - 1;
// }
// await InsertInspection<NoneDicomStudyFile>(item, type, x => new DataInspection()
// await InsertInspection<NoneDicomStudyFile>(item.Entity, type, x => new DataInspection()
// {
// GeneralId = x.Id,
// TrialId = noneDicomStudy.TrialId,
@ -578,19 +558,19 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//一致性核查
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog)))
{
type = _userInfo.UserTypeShortName + "/" + type;
var entity = item.Entity as CheckChallengeDialog;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
var reason = string.Empty;
switch (GetRequestUrl().ToLower())
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closecheckchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
await InsertInspection<CheckChallengeDialog>(item, type, x => new DataInspection()
await InsertInspection<CheckChallengeDialog>(item.Entity, type, x => new DataInspection()
{
GeneralId = entity.SubjectVisitId,
TrialId = subjectvisit.TrialId,
@ -615,31 +595,14 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as SubjectVisit;
string reason = string.Empty;
switch (GetRequestUrl().ToLower())
if (_userInfo.RequestUrl.ToLower() == "qcoperation/setcheckpass")
{
case "qcoperation/obtainorcancelqctask":
type = type + "/" + entity.IsTake.ToString();
break;
// 设置通过一致性核查
case "qcoperation/setcheckpass":
reason = entity.ManualPassReason;
break;
case "qcoperation/qcpassedorfailed":
try
{
type = type + "/" + (40 % (int)entity.AuditState).ToString();
}
catch (Exception)
{
}
break;
reason = entity.ManualPassReason;
}
var subjectCode = entity.Subject?.Code;
await InsertInspection<SubjectVisit>(item, type, x => new DataInspection()
await InsertInspection<SubjectVisit>(item.Entity, type, x => new DataInspection()
{
SubjectCode = subjectCode,
SubjectId = x.SubjectId,
@ -656,7 +619,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as PreviousSurgery;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
await InsertInspection<PreviousSurgery>(item, type, x => new DataInspection()
await InsertInspection<PreviousSurgery>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
SiteId = subjectvisit.SiteId,
@ -676,7 +639,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as PreviousHistory;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
await InsertInspection<PreviousHistory>(item, type, x => new DataInspection()
await InsertInspection<PreviousHistory>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
SiteId = subjectvisit.SiteId,
@ -695,7 +658,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as PreviousOther;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
await InsertInspection<PreviousOther>(item, type, x => new DataInspection()
await InsertInspection<PreviousOther>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
SiteId = subjectvisit.SiteId,
@ -712,7 +675,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge)))
{
var entity = item.Entity as QCChallenge;
type = _userInfo.UserTypeShortName + "/" + type;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
var content = string.Empty;
@ -720,7 +683,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
content = entity.Content;
}
await InsertInspection<QCChallenge>(item, type, x => new DataInspection()
await InsertInspection<QCChallenge>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
TrialId = x.TrialId,
@ -743,18 +706,18 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
var reason = string.Empty;
var entity = item.Entity as QCChallengeDialog;
switch (GetRequestUrl().ToLower())
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closeqcchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
type = _userInfo.UserTypeShortName + "/" + type;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
var qCChallenge = await _dbContext.QCChallenge.Where(x => x.Id == entity.QCChallengeId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
qCChallenge = qCChallenge ?? new QCChallenge();
await InsertInspection<QCChallengeDialog>(item, type, x => new DataInspection()
await InsertInspection<QCChallengeDialog>(item.Entity, type, x => new DataInspection()
{
GeneralId = qCChallenge.Id,
TrialId = subjectvisit.TrialId,
@ -780,7 +743,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//Qc 问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion)))
{
await InsertInspection<QCQuestion>(item, type, x => new DataInspection()
await InsertInspection<QCQuestion>(item.Entity, type, x => new DataInspection()
{
GeneralId = x.Id,
});
@ -855,7 +818,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
// subjectvisit = subjectvisit ?? new SubjectVisit();
// type = type == "Update" ? "Add" : type;
// await InsertInspection<TrialQCQuestionAnswer>(item, type, x => new DataInspection()
// await InsertInspection<TrialQCQuestionAnswer>(item.Entity, type, x => new DataInspection()
// {
// SiteId= subjectvisit.SiteId,
// SubjectId= subjectvisit.SubjectId,
@ -873,21 +836,20 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// 插入稽查实体
/// </summary>
/// <typeparam name="T">泛型</typeparam>
/// <param name="data">数据 EF 跟踪实体信息 </param>
/// <param name="type">类型 Add|Update|delete</param>
/// <param name="expression">表达式 稽查实体部分字段赋值</param>
/// <param name="otherItem">实体对象 添加到稽查记录详细Json 匿名对象</param>
/// <param name="entityData">实体名称</param>
/// <param name="data">数据</param>
/// <param name="type">类型</param>
/// <param name="expression">表达式</param>
/// <param name="otherItem">其他对象</param>
/// <returns></returns>
public async Task InsertInspection<T>(EntityEntry data, string type, Expression<Func<T, DataInspection>> expression = null, object otherItem = null, T entityData = null) where T : class
public async Task InsertInspection<T>(object data, string type, Expression<Func<T, DataInspection>> expression = null, object otherItem = null,object originaldata=null) where T : class
{
object entityobj = entityData == null ? data.Entity : entityData;
object entityobj = data;
DataInspection inspection = new DataInspection();
if (expression != null)
{
var f = expression.Compile();
var entity = entityobj as T;
inspection = f(entity);
var entitydata = entityobj as T;
inspection = f(entitydata);
}
var entityTypeName = entityobj.GetType().Name;
@ -900,6 +862,63 @@ namespace IRaCIS.Core.Infra.EFCore.Common
dynamic entity;
switch (entityobj.GetType().Name)
{
case nameof(QCChallengeDialog):
case nameof(QCChallenge):
case nameof(CheckChallengeDialog):
type = type + "/(" + _userInfo.UserTypeShortName + ")";
break;
case nameof(NoneDicomStudy):
switch (_userInfo.RequestUrl.ToLower())
{
case "nonedicomstudy/addorupdatenonedicomstudy":
type = type + "/("+ _userInfo.UserTypeShortName + ")";
break;
}
break;
case nameof(SystemBasicData):
entity = entityobj as SystemBasicData;
type = type + (entity.ParentId == null ? "/parent" : string.Empty);
break;
case nameof(Trial):
entity = originaldata as Trial;
switch (_userInfo.RequestUrl.ToLower())
{
case "configtrialbasicinfo/configtrialbasicinfoconfirm":
type = type + "/" + entity.IsTrialBasicLogicConfirmed.ToString();
break;
case "configtrialbasicinfo/configtrialprocessinfoconfirm":
type = type + "/" + entity.IsTrialProcessConfirmed.ToString();
break;
case "configtrialbasicinfo/configtrialurgentinfoconfirm":
type = type + "/" + entity.IsTrialUrgentConfirmed.ToString();
break;
}
break;
case nameof(SubjectVisit):
entity = originaldata as SubjectVisit;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/obtainorcancelqctask":
type = type + "/" + entity.IsTake.ToString();
break;
case "qcoperation/qcpassedorfailed":
try
{
type = type + "/" + (40 % (int)entity.AuditState).ToString();
}
catch (Exception)
{
}
break;
}
break;
}
inspection.Identification = $"{_userInfo.RequestUrl}/{ entityTypeName}/{type}";
@ -926,10 +945,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// 获取URl参数
/// </summary>
/// <returns></returns>
public string GetRequestUrl()
{
return _userInfo.RequestUrl;
}
//public string GetRequestUrl()
//{
// return _userInfo.RequestUrl;
//}
/// <summary>
/// 映射数据