修改稽查

Uat_Study
hang 2022-08-19 16:59:53 +08:00
parent 5a24add4bf
commit 855df63891
2 changed files with 256 additions and 320 deletions

View File

@ -121,10 +121,10 @@ namespace IRaCIS.Core.Domain.Models
/// </summary> /// </summary>
public string Identification { get; set; } public string Identification { get; set; }
/// <summary> ///// <summary>
/// 访视计划ID ///// 访视计划ID
/// </summary> ///// </summary>
public Guid? VisitStageId { get; set; } //public Guid? VisitStageId { get; set; }
/// <summary> /// <summary>
/// 通用Id /// 通用Id

View File

@ -113,10 +113,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList(); var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList();
var userTypeNameList = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync(); var userTypeNameList = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync();
var userTypeName = string.Join(",", userTypeNameList); var userTypeName = string.Join(",", userTypeNameList);
await InsertInspection<SystemDocument>(entity, type, x => new InspectionConvertDTO() await InsertInspection<SystemDocument>(entity, type, null, new
{
GeneralId = x.Id
}, new
{ {
NeedConfirmedUserType = userTypeName, NeedConfirmedUserType = userTypeName,
}); });
@ -125,10 +122,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 签名模板 // 签名模板
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemBasicData))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemBasicData)))
{ {
await InsertInspection<SystemBasicData>(item.Entity as SystemBasicData, type, x => new InspectionConvertDTO() await InsertInspection<SystemBasicData>(item.Entity as SystemBasicData, type);
{
GeneralId = x.Id,
});
} }
// 项目 // 项目
@ -157,7 +151,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
TrialId = x.Id, TrialId = x.Id,
TrialName = x.ExperimentName, TrialName = x.ExperimentName,
ResearchProgramNo = x.ResearchProgramNo, ResearchProgramNo = x.ResearchProgramNo,
GeneralId = x.Id,
}, new }, new
{ {
TrialDicList = string.Join(",", trialDics) TrialDicList = string.Join(",", trialDics)
@ -175,11 +168,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
visitPlanStatus = false; visitPlanStatus = false;
} }
await InsertInspection<VisitStage>(item.Entity as VisitStage, type, x => new InspectionConvertDTO() await InsertInspection<VisitStage>(item.Entity as VisitStage, type, null, new
{
VisitStageId = x.Id,
GeneralId = x.Id,
}, new
{ {
VisitPlanStatus = visitPlanStatus, VisitPlanStatus = visitPlanStatus,
}); });
@ -199,10 +188,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList(); 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 usertypeNames = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync();
var usertypeName = string.Join(",", usertypeNames); var usertypeName = string.Join(",", usertypeNames);
await InsertInspection<TrialDocument>(entity, type, x => new InspectionConvertDTO() await InsertInspection<TrialDocument>(entity, type, null, new
{
GeneralId = x.Id
}, new
{ {
NeedConfirmedUserType = usertypeName, NeedConfirmedUserType = usertypeName,
}); });
@ -238,7 +224,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
await InsertInspection<TrialDocUserTypeConfirmedUser>(entity as TrialDocUserTypeConfirmedUser, type, x => new InspectionConvertDTO() await InsertInspection<TrialDocUserTypeConfirmedUser>(entity as TrialDocUserTypeConfirmedUser, type, x => new InspectionConvertDTO()
{ {
TrialId = trialid, TrialId = trialid,
GeneralId = x.Id,
}, new }, new
{ {
FileTypeId = trialDocument.FileTypeId, FileTypeId = trialDocument.FileTypeId,
@ -257,11 +242,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
entity.Site = await _dbContext.Site.Where(x => x.Id == entity.SiteId).FirstOrDefaultAsync(); entity.Site = await _dbContext.Site.Where(x => x.Id == entity.SiteId).FirstOrDefaultAsync();
} }
await InsertInspection<TrialSite>(entity, type, x => new InspectionConvertDTO() await InsertInspection<TrialSite>(entity, type,null, new
{
GeneralId = x.Id,
}, new
{ {
TrialSiteCode = entity.TrialSiteCode, TrialSiteCode = entity.TrialSiteCode,
SiteName = entity.Site.SiteName, SiteName = entity.Site.SiteName,
@ -324,10 +305,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
UserType userType = new UserType(); UserType userType = new UserType();
userType = await _dbContext.UserType.Where(x => x.Id == user.UserTypeId).FirstOrDefaultAsync(); userType = await _dbContext.UserType.Where(x => x.Id == user.UserTypeId).FirstOrDefaultAsync();
await InsertInspection<TrialSiteUser>(item.Entity as TrialSiteUser, type, x => new InspectionConvertDTO() await InsertInspection<TrialSiteUser>(item.Entity as TrialSiteUser, type, null, new
{
GeneralId = x.Id,
}, new
{ {
TrialSiteCode = entity.TrialSite.TrialSiteCode, TrialSiteCode = entity.TrialSite.TrialSiteCode,
SiteName = entity.Site.SiteName, SiteName = entity.Site.SiteName,
@ -364,12 +342,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
entity.ReviewerUser = await _dbContext.User.Where(x => x.Id == entity.ReviewerUserId).FirstOrDefaultAsync(); entity.ReviewerUser = await _dbContext.User.Where(x => x.Id == entity.ReviewerUserId).FirstOrDefaultAsync();
} }
await InsertInspection<TrialSiteSurvey>(item.Entity as TrialSiteSurvey, type, x => new InspectionConvertDTO() await InsertInspection<TrialSiteSurvey>(item.Entity as TrialSiteSurvey, type, null, new
{
GeneralId = x.Id,
}, new
{ {
TrialSiteCode = entity.TrialSite.TrialSiteCode, TrialSiteCode = entity.TrialSite.TrialSiteCode,
TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName, TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName,
@ -386,10 +359,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
var entity = item.Entity as TrialQCQuestion; var entity = item.Entity as TrialQCQuestion;
var paretName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync(); var paretName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync();
await InsertInspection<TrialQCQuestion>(entity, type, x => new InspectionConvertDTO() await InsertInspection<TrialQCQuestion>(entity, type,null, new
{
GeneralId = x.Id,
}, new
{ {
QuestionName = entity.QuestionName, QuestionName = entity.QuestionName,
Type = entity.Type, Type = entity.Type,
@ -403,30 +373,11 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}); });
} }
// 受试者
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject)))
{
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>(entity, type, x => new InspectionConvertDTO()
{
GeneralId=x.Id,
SubjectId = x.Id,
SubjectCode = x.Code,
}, new
{
FinalSubjectVisitName = finalSubjectVisitName,
});
}
// 检查 // 检查
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy)))
{ {
await InsertInspection<DicomStudy>(item.Entity as DicomStudy, type, x => new InspectionConvertDTO() await InsertInspection<DicomStudy>(item.Entity as DicomStudy, type);
{
GeneralId = x.Id,
});
} }
// 序列 // 序列
@ -438,10 +389,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
dicomStudy = await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x => x.Id == entity.StudyId); dicomStudy = await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x => x.Id == entity.StudyId);
} }
await InsertInspection<DicomSeries>(item.Entity as DicomSeries, type, x => new InspectionConvertDTO() await InsertInspection<DicomSeries>(item.Entity as DicomSeries, type,null, new
{
GeneralId = x.Id,
}, new
{ {
StudyCode = dicomStudy?.StudyCode, StudyCode = dicomStudy?.StudyCode,
Modalities = dicomStudy?.Modalities, Modalities = dicomStudy?.Modalities,
@ -456,10 +404,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var fileCount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync(); var fileCount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync();
await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new InspectionConvertDTO() await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, null, new
{
GeneralId = x.Id,
}, new
{ {
FileCount = fileCount, FileCount = fileCount,
}); });
@ -483,10 +428,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
filecount = filecount + count; filecount = filecount + count;
} }
await InsertInspection<NoneDicomStudy>(noneDicomStudy, type, x => new InspectionConvertDTO() await InsertInspection<NoneDicomStudy>(noneDicomStudy, type,null, new
{
GeneralId = x.Id,
}, new
{ {
FileCount = filecount, FileCount = filecount,
}); });
@ -495,40 +437,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
//一致性核查 // 特殊GeneralId
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog)))
{
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 (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closecheckchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
await InsertInspection<CheckChallengeDialog>(entity, type, x => new InspectionConvertDTO()
{
GeneralId = entity.SubjectVisitId,
TrialId = subjectvisit.TrialId,
SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId,
SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName,
Reason = reason,
CreateTime = x.CreateTime,
}, new
{
CheckState = subjectvisit.CheckState,
RequestBackState = subjectvisit.RequestBackState,
CheckChallengeState = subjectvisit.CheckChallengeState,
});
}
// 访视 // 访视
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit)))
{ {
@ -544,7 +452,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var subjectCode = entity.Subject?.Code; var subjectCode = entity.Subject?.Code;
await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO() await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO()
{ {
GeneralId=x.Id,
SubjectCode = subjectCode, SubjectCode = subjectCode,
SubjectId = x.SubjectId, SubjectId = x.SubjectId,
SubjectVisitId = x.Id, SubjectVisitId = x.Id,
@ -562,7 +469,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
subjectvisit = subjectvisit ?? new SubjectVisit(); subjectvisit = subjectvisit ?? new SubjectVisit();
await InsertInspection<PreviousSurgery>(entity, type, x => new InspectionConvertDTO() await InsertInspection<PreviousSurgery>(entity, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
SiteId = subjectvisit.SiteId, SiteId = subjectvisit.SiteId,
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectvisit.VisitName,
TrialId = subjectvisit.TrialId, TrialId = subjectvisit.TrialId,
@ -582,7 +488,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
subjectvisit = subjectvisit ?? new SubjectVisit(); subjectvisit = subjectvisit ?? new SubjectVisit();
await InsertInspection<PreviousHistory>(entity, type, x => new InspectionConvertDTO() await InsertInspection<PreviousHistory>(entity, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
SiteId = subjectvisit.SiteId, SiteId = subjectvisit.SiteId,
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectvisit.VisitName,
TrialId = subjectvisit.TrialId, TrialId = subjectvisit.TrialId,
@ -601,7 +506,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
subjectvisit = subjectvisit ?? new SubjectVisit(); subjectvisit = subjectvisit ?? new SubjectVisit();
await InsertInspection<PreviousOther>(entity, type, x => new InspectionConvertDTO() await InsertInspection<PreviousOther>(entity, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
SiteId = subjectvisit.SiteId, SiteId = subjectvisit.SiteId,
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectvisit.VisitName,
TrialId = subjectvisit.TrialId, TrialId = subjectvisit.TrialId,
@ -626,7 +530,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
await InsertInspection<QCChallenge>(entity, type, x => new InspectionConvertDTO() await InsertInspection<QCChallenge>(entity, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
TrialId = x.TrialId, TrialId = x.TrialId,
SubjectVisitId = x.SubjectVisitId, SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId, SiteId = subjectvisit.SiteId,
@ -642,62 +545,18 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}); });
} }
// 质疑信息 // 特殊GeneralId
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallengeDialog)))
{
var reason = string.Empty;
var entity = item.Entity as QCChallengeDialog;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closeqcchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
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>(entity, type, x => new InspectionConvertDTO()
{
GeneralId = qCChallenge.Id,
TrialId = subjectvisit.TrialId,
SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId,
SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName,
Reason = reason,
}, new
{
AuditState = subjectvisit.AuditState,
ReuploadEnum = qCChallenge.ReuploadEnum,
Content = qCChallenge.Content,
DeadlineTime = qCChallenge.DeadlineTime,
IsOverTime = qCChallenge.IsClosed ? qCChallenge.ClosedTime > qCChallenge.DeadlineTime : DateTime.Now > qCChallenge.DeadlineTime,
IsClosed = qCChallenge.IsClosed
});
}
//Qc 问题 //Qc 问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion)))
{ {
await InsertInspection<QCQuestion>(item.Entity as QCQuestion, type, x => new InspectionConvertDTO() await InsertInspection<QCQuestion>(item.Entity as QCQuestion, type);
{
GeneralId = x.Id,
});
} }
// 一致性核查文件 // 一致性核查文件
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile)))
{ {
await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO() await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
CreateTime = x.CreateTime, CreateTime = x.CreateTime,
}); });
} }
@ -791,24 +650,80 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
#region 备注 //一致性核查 // 特殊GeneralId
////Qc 问题答案 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog)))
//foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer))) {
//{
// var entity = item.Entity as TrialQCQuestionAnswer;
// 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.Entity, type, x => new DataInspection()
// {
// SiteId= subjectvisit.SiteId,
// SubjectId= subjectvisit.SubjectId,
// SubjectVisitName= subjectvisit.VisitName,
// GeneralId = x.Id,
// });
//}
#endregion
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 (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closecheckchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
await InsertInspection<CheckChallengeDialog>(entity, type, x => new InspectionConvertDTO()
{
GeneralId = entity.SubjectVisitId,
TrialId = subjectvisit.TrialId,
SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId,
SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName,
Reason = reason,
CreateTime = x.CreateTime,
}, new
{
CheckState = subjectvisit.CheckState,
RequestBackState = subjectvisit.RequestBackState,
CheckChallengeState = subjectvisit.CheckChallengeState,
});
}
// 质疑信息 // 特殊GeneralId
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallengeDialog)))
{
var reason = string.Empty;
var entity = item.Entity as QCChallengeDialog;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closeqcchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
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>(entity, type, x => new InspectionConvertDTO()
{
GeneralId = qCChallenge.Id,
TrialId = subjectvisit.TrialId,
SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId,
SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName,
Reason = reason,
}, new
{
AuditState = subjectvisit.AuditState,
ReuploadEnum = qCChallenge.ReuploadEnum,
Content = qCChallenge.Content,
DeadlineTime = qCChallenge.DeadlineTime,
IsOverTime = qCChallenge.IsClosed ? qCChallenge.ClosedTime > qCChallenge.DeadlineTime : DateTime.Now > qCChallenge.DeadlineTime,
IsClosed = qCChallenge.IsClosed
});
}
#region 阅片人入组
//阅片人入组 //阅片人入组
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll)))
@ -848,6 +763,25 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}); });
} }
#endregion
#region Subject 阅片期和 临床数据
// 受试者
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject)))
{
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>(entity, type, x => new InspectionConvertDTO()
{
SubjectId = x.Id,
SubjectCode = x.Code,
}, new
{
FinalSubjectVisitName = finalSubjectVisitName,
});
}
//阅片期计划 //阅片期计划
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingPeriodSet))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingPeriodSet)))
@ -866,10 +800,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
await InsertInspection<ReadingPeriodSet>(item.Entity as ReadingPeriodSet, type, x => new InspectionConvertDTO() await InsertInspection<ReadingPeriodSet>(item.Entity as ReadingPeriodSet, type, null, new
{
GeneralId = x.Id,
}, new
{ {
VisitName = visitName, VisitName = visitName,
SiteCodes = siteCodes SiteCodes = siteCodes
@ -908,7 +839,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var visitName = _dbContext.SubjectVisit.Where(t => t.Id == entity.SubjectVisitId).Select(t => t.VisitName).FirstOrDefault(); var visitName = _dbContext.SubjectVisit.Where(t => t.Id == entity.SubjectVisitId).Select(t => t.VisitName).FirstOrDefault();
await InsertInspection<ReadModule>(item.Entity as ReadModule, type, x => new InspectionConvertDTO() await InsertInspection<ReadModule>(item.Entity as ReadModule, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
ObjectRelationParentId = entity.ReadingPeriodSetId, ObjectRelationParentId = entity.ReadingPeriodSetId,
SubjectVisitId = x.SubjectVisitId, SubjectVisitId = x.SubjectVisitId,
IsDistinctionInterface = false, IsDistinctionInterface = false,
@ -932,7 +862,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO() await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
SubjectVisitId = x.IsVisit ? x.ReadingId : null, SubjectVisitId = x.IsVisit ? x.ReadingId : null,
}, new }, new
{ {
@ -948,10 +877,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
await InsertInspection<ReadingClinicalDataPDF>(item.Entity as ReadingClinicalDataPDF, type, x => new InspectionConvertDTO() await InsertInspection<ReadingClinicalDataPDF>(item.Entity as ReadingClinicalDataPDF, type, x => new InspectionConvertDTO()
{ {
GeneralId = x.Id,
SubjectId = x.SubjectId, SubjectId = x.SubjectId,
IsDistinctionInterface=false, IsDistinctionInterface = false,
ObjectRelationParentId=entity.ReadingClinicalDataId ObjectRelationParentId = entity.ReadingClinicalDataId
}, new }, new
{ {
IsCRCUpload = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator IsCRCUpload = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator
@ -959,6 +887,11 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
#endregion
#endregion #endregion
} }
@ -977,6 +910,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
InspectionConvertDTO inspection = new InspectionConvertDTO(); InspectionConvertDTO inspection = new InspectionConvertDTO();
if (expression != null) if (expression != null)
{ {
var f = expression.Compile(); var f = expression.Compile();
@ -984,8 +919,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
inspection = f(entityObj); inspection = f(entityObj);
} }
//避免重复赋值 //避免重复赋值 有些特殊的GeneralId
inspection.GeneralId = entityObj.Id; var generalId = (inspection.GeneralId != null && inspection.GeneralId != Guid.Empty) ? inspection.GeneralId : entityObj.Id ;
inspection.GeneralId = generalId;
inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj, type, inspection.IsDistinctionInterface); inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj, type, inspection.IsDistinctionInterface);
@ -1008,7 +944,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#endregion #endregion
if (inspection.ParentId == null) if (inspection.ParentId == null)
{ {
inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == inspection.TrialId && x.SubjectVisitId == inspection.SubjectVisitId && x.SubjectId == inspection.SubjectId && x.SiteId == inspection.SiteId && x.VisitStageId == inspection.VisitStageId && x.GeneralId == inspection.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == inspection.TrialId && x.SubjectVisitId == inspection.SubjectVisitId && x.SubjectId == inspection.SubjectId && x.SiteId == inspection.SiteId && x.GeneralId == inspection.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
} }
inspection.CreateUserId = _userInfo.Id; inspection.CreateUserId = _userInfo.Id;
inspection.IP = _userInfo.IP; inspection.IP = _userInfo.IP;
@ -1309,177 +1245,177 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#region 待废弃 -by zhouhang 调整 #region 待废弃 -by zhouhang 调整
/// <summary> ///// <summary>
/// 映射数据 ///// 映射数据
/// </summary> ///// </summary>
/// <param name="data"></param> ///// <param name="data"></param>
/// <param name="mapData">要赋值的对象</param> ///// <param name="mapData">要赋值的对象</param>
public void MapData(dynamic data, dynamic mapData) //public void MapData(dynamic data, dynamic mapData)
{ //{
List<string> column = new List<string>() { "TrialId", "SiteId", "SubjectId", "SubjectVisitId", "CreateUserName", "TrialName", "SiteName", "SubjectCode", "VisitName", "SubjectVisitName", "RoleName", "SiteCode", "ResearchProgramNo" }; // List<string> column = new List<string>() { "TrialId", "SiteId", "SubjectId", "SubjectVisitId", "CreateUserName", "TrialName", "SiteName", "SubjectCode", "VisitName", "SubjectVisitName", "RoleName", "SiteCode", "ResearchProgramNo" };
foreach (var item in column) // foreach (var item in column)
{ // {
try // try
{ // {
var i = mapData.GetType().GetProperty(item).GetValue(mapData); // var i = mapData.GetType().GetProperty(item).GetValue(mapData);
if (i == null || i == default(Guid)) // if (i == null || i == default(Guid))
{ // {
var value = data.GetType().GetProperty(item).GetValue(data); // var value = data.GetType().GetProperty(item).GetValue(data);
mapData.GetType().GetProperty(item).SetValue(mapData, value); // mapData.GetType().GetProperty(item).SetValue(mapData, value);
} // }
} // }
catch (Exception) // catch (Exception)
{ // {
continue; // continue;
} // }
} // }
} //}
/// <summary> ///// <summary>
/// 添加稽查 ///// 添加稽查
/// </summary> ///// </summary>
/// <param name="add">新增的稽查对象</param> ///// <param name="add">新增的稽查对象</param>
/// <param name="data">数据</param> ///// <param name="data">数据</param>
/// <returns></returns> ///// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception> ///// <exception cref="BusinessValidationFailedException"></exception>
public async Task AddInspectionRecordAsync<T>(T data, InspectionConvertDTO add, object otherItem = null) where T : class //public async Task AddInspectionRecordAsync<T>(T data, InspectionConvertDTO add, object otherItem = null) where T : class
{ //{
//MapData(data, add); // //MapData(data, add);
MapEntityPropertyToAuditEntity(data, add); // MapEntityPropertyToAuditEntity(data, add);
InspectionGeneralData generalData = new InspectionGeneralData() // InspectionGeneralData generalData = new InspectionGeneralData()
{ // {
//CreateUserName = add.CreateUserName, // //CreateUserName = add.CreateUserName,
SiteCode = add.SiteCode, // SiteCode = add.SiteCode,
SiteId = add.SiteId, // SiteId = add.SiteId,
//SiteName = add.SiteName, // //SiteName = add.SiteName,
SubjectCode = add.SubjectCode, // SubjectCode = add.SubjectCode,
SubjectId = add.SubjectId, // SubjectId = add.SubjectId,
SubjectVisitId = add.SubjectVisitId, // SubjectVisitId = add.SubjectVisitId,
SubjectVisitName = add.SubjectVisitName, // SubjectVisitName = add.SubjectVisitName,
ResearchProgramNo = add.ResearchProgramNo, // ResearchProgramNo = add.ResearchProgramNo,
//RoleName = add.RoleName, // //RoleName = add.RoleName,
TrialId = add.TrialId, // TrialId = add.TrialId,
TrialName = add.TrialName // TrialName = add.TrialName
}; // };
await SetInspectionNameValue(generalData); // await SetInspectionNameValue(generalData);
#region 处理标识 // #region 处理标识
var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == add.Identification); // var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == add.Identification);
add.ObjectTypeId = from?.ObjectTypeId; // add.ObjectTypeId = from?.ObjectTypeId;
add.OptTypeId = from?.OptTypeId; // add.OptTypeId = from?.OptTypeId;
add.ChildrenTypeId = from?.ChildrenTypeId; // add.ChildrenTypeId = from?.ChildrenTypeId;
add.ModuleTypeId = from?.ModuleTypeId; // add.ModuleTypeId = from?.ModuleTypeId;
#endregion // #endregion
if (add.ParentId == null) // 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.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; // 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.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
} // }
add.CreateUserId = _userInfo.Id; // add.CreateUserId = _userInfo.Id;
add.IP = _userInfo.IP; // add.IP = _userInfo.IP;
add.CreateTime = add.CreateTime == default(DateTime) ? DateTime.Now : add.CreateTime; // add.CreateTime = add.CreateTime == default(DateTime) ? DateTime.Now : add.CreateTime;
if (_userInfo.SignId != null) // if (_userInfo.SignId != null)
{ // {
add.SignId = _userInfo.SignId; // add.SignId = _userInfo.SignId;
add.IsSign = true; // add.IsSign = true;
} // }
var inspectionData = new InspectionJsonDetail() // var inspectionData = new InspectionJsonDetail()
{ // {
//稽查实体,加上扩充的信息 // //稽查实体,加上扩充的信息
Data = AddJsonItem(data, otherItem), // Data = AddJsonItem(data, otherItem),
//通用信息 // //通用信息
CommonData = generalData // CommonData = generalData
}; // };
add.JsonDetail = inspectionData.ToJsonStr(); // add.JsonDetail = inspectionData.ToJsonStr();
add.BatchId = _userInfo.BatchId.Value; // add.BatchId = _userInfo.BatchId.Value;
await _dbContext.DataInspection.AddAsync(add); // await _dbContext.DataInspection.AddAsync(add);
} //}
/// <summary> ///// <summary>
/// 设置项目以及名称 ///// 设置项目以及名称
/// </summary> ///// </summary>
/// <param name="generalData"></param> ///// <param name="generalData"></param>
/// <returns></returns> ///// <returns></returns>
public async Task SetInspectionNameValue(InspectionGeneralData generalData) //public async Task SetInspectionNameValue(InspectionGeneralData generalData)
{ //{
#region 项目名称 // #region 项目名称
if (generalData.TrialId != null) // if (generalData.TrialId != null)
{ // {
//项目添加哪里 直接会带信息过来,不用查询数据库 其他的地方需要查询数据库 // //项目添加哪里 直接会带信息过来,不用查询数据库 其他的地方需要查询数据库
if (string.IsNullOrEmpty(generalData.ResearchProgramNo) || string.IsNullOrEmpty(generalData.TrialName)) // if (string.IsNullOrEmpty(generalData.ResearchProgramNo) || string.IsNullOrEmpty(generalData.TrialName))
{ // {
var trialdata = (await _dbContext.Trial.Select(x => new { x.Id, x.ResearchProgramNo, x.ExperimentName, }).FirstOrDefaultAsync(x => x.Id == generalData.TrialId)).IfNullThrowException(); // var trialdata = (await _dbContext.Trial.Select(x => new { x.Id, x.ResearchProgramNo, x.ExperimentName, }).FirstOrDefaultAsync(x => x.Id == generalData.TrialId)).IfNullThrowException();
generalData.ResearchProgramNo = trialdata.ResearchProgramNo; // generalData.ResearchProgramNo = trialdata.ResearchProgramNo;
generalData.TrialName = trialdata.ExperimentName; // generalData.TrialName = trialdata.ExperimentName;
} // }
} // }
#endregion // #endregion
#region 测试中心名称 // #region 测试中心名称
if (generalData.TrialId != null && generalData.SiteId != null) // if (generalData.TrialId != null && generalData.SiteId != null)
{ // {
generalData.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().Where(x => x.TrialId == generalData.TrialId && x.SiteId == generalData.SiteId).Select(t => t.TrialSiteCode).FirstOrDefaultAsync()).IfNullThrowException(); // generalData.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().Where(x => x.TrialId == generalData.TrialId && x.SiteId == generalData.SiteId).Select(t => t.TrialSiteCode).FirstOrDefaultAsync()).IfNullThrowException();
//// 添加Site 哪里会带信息过来 // //// 添加Site 哪里会带信息过来
//if (string.IsNullOrEmpty(generalData.SiteName)) // //if (string.IsNullOrEmpty(generalData.SiteName))
//{ // //{
// generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException(); // // generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException();
//} // //}
} // }
#endregion // #endregion
#region 受试者 // #region 受试者
if (generalData.SubjectId != null) // if (generalData.SubjectId != null)
{ // {
// 添加Subject 哪里会带信息过来 // // 添加Subject 哪里会带信息过来
if (string.IsNullOrEmpty(generalData.SubjectCode)) // if (string.IsNullOrEmpty(generalData.SubjectCode))
{ // {
generalData.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => x.Code).FirstOrDefaultAsync()).IfNullThrowException(); // generalData.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => x.Code).FirstOrDefaultAsync()).IfNullThrowException();
} // }
} // }
#endregion // #endregion
#region 访视 // #region 访视
if (generalData.SubjectVisitId != null) // if (generalData.SubjectVisitId != null)
{ // {
//添加访视的时候,会带信息过来 // //添加访视的时候,会带信息过来
if (string.IsNullOrEmpty(generalData.SubjectVisitName)) // if (string.IsNullOrEmpty(generalData.SubjectVisitName))
{ // {
generalData.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => x.VisitName).FirstOrDefaultAsync()).IfNullThrowException(); // generalData.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => x.VisitName).FirstOrDefaultAsync()).IfNullThrowException();
} // }
} // }
#endregion // #endregion
} //}
#endregion #endregion