修改稽查
parent
5a24add4bf
commit
855df63891
|
@ -121,10 +121,10 @@ namespace IRaCIS.Core.Domain.Models
|
|||
/// </summary>
|
||||
public string Identification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访视计划ID
|
||||
/// </summary>
|
||||
public Guid? VisitStageId { get; set; }
|
||||
///// <summary>
|
||||
///// 访视计划ID
|
||||
///// </summary>
|
||||
//public Guid? VisitStageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通用Id
|
||||
|
|
|
@ -113,10 +113,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
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 userTypeName = string.Join(",", userTypeNameList);
|
||||
await InsertInspection<SystemDocument>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id
|
||||
}, new
|
||||
await InsertInspection<SystemDocument>(entity, type, null, new
|
||||
{
|
||||
NeedConfirmedUserType = userTypeName,
|
||||
});
|
||||
|
@ -125,10 +122,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
// 签名模板
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemBasicData)))
|
||||
{
|
||||
await InsertInspection<SystemBasicData>(item.Entity as SystemBasicData, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
});
|
||||
await InsertInspection<SystemBasicData>(item.Entity as SystemBasicData, type);
|
||||
}
|
||||
|
||||
// 项目
|
||||
|
@ -157,7 +151,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
TrialId = x.Id,
|
||||
TrialName = x.ExperimentName,
|
||||
ResearchProgramNo = x.ResearchProgramNo,
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
{
|
||||
TrialDicList = string.Join(",", trialDics)
|
||||
|
@ -175,11 +168,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
{
|
||||
visitPlanStatus = false;
|
||||
}
|
||||
await InsertInspection<VisitStage>(item.Entity as VisitStage, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
VisitStageId = x.Id,
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
await InsertInspection<VisitStage>(item.Entity as VisitStage, type, null, new
|
||||
{
|
||||
VisitPlanStatus = visitPlanStatus,
|
||||
});
|
||||
|
@ -199,10 +188,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>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id
|
||||
}, new
|
||||
await InsertInspection<TrialDocument>(entity, type, null, new
|
||||
{
|
||||
NeedConfirmedUserType = usertypeName,
|
||||
});
|
||||
|
@ -238,7 +224,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
await InsertInspection<TrialDocUserTypeConfirmedUser>(entity as TrialDocUserTypeConfirmedUser, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
TrialId = trialid,
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
{
|
||||
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();
|
||||
}
|
||||
await InsertInspection<TrialSite>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
|
||||
}, new
|
||||
await InsertInspection<TrialSite>(entity, type,null, new
|
||||
{
|
||||
TrialSiteCode = entity.TrialSiteCode,
|
||||
SiteName = entity.Site.SiteName,
|
||||
|
@ -324,10 +305,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.Entity as TrialSiteUser, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
await InsertInspection<TrialSiteUser>(item.Entity as TrialSiteUser, type, null, new
|
||||
{
|
||||
TrialSiteCode = entity.TrialSite.TrialSiteCode,
|
||||
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();
|
||||
}
|
||||
|
||||
await InsertInspection<TrialSiteSurvey>(item.Entity as TrialSiteSurvey, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
|
||||
|
||||
}, new
|
||||
await InsertInspection<TrialSiteSurvey>(item.Entity as TrialSiteSurvey, type, null, new
|
||||
{
|
||||
TrialSiteCode = entity.TrialSite.TrialSiteCode,
|
||||
TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName,
|
||||
|
@ -386,10 +359,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>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
await InsertInspection<TrialQCQuestion>(entity, type,null, new
|
||||
{
|
||||
QuestionName = entity.QuestionName,
|
||||
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)))
|
||||
{
|
||||
await InsertInspection<DicomStudy>(item.Entity as DicomStudy, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
});
|
||||
await InsertInspection<DicomStudy>(item.Entity as DicomStudy, type);
|
||||
}
|
||||
|
||||
// 序列
|
||||
|
@ -438,10 +389,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
{
|
||||
dicomStudy = await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x => x.Id == entity.StudyId);
|
||||
}
|
||||
await InsertInspection<DicomSeries>(item.Entity as DicomSeries, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
await InsertInspection<DicomSeries>(item.Entity as DicomSeries, type,null, new
|
||||
{
|
||||
StudyCode = dicomStudy?.StudyCode,
|
||||
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();
|
||||
|
||||
|
||||
await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, null, new
|
||||
{
|
||||
FileCount = fileCount,
|
||||
});
|
||||
|
@ -483,10 +428,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
filecount = filecount + count;
|
||||
}
|
||||
|
||||
await InsertInspection<NoneDicomStudy>(noneDicomStudy, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
await InsertInspection<NoneDicomStudy>(noneDicomStudy, type,null, new
|
||||
{
|
||||
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)))
|
||||
{
|
||||
|
@ -544,7 +452,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
var subjectCode = entity.Subject?.Code;
|
||||
await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId=x.Id,
|
||||
SubjectCode = subjectCode,
|
||||
SubjectId = x.SubjectId,
|
||||
SubjectVisitId = x.Id,
|
||||
|
@ -562,7 +469,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
subjectvisit = subjectvisit ?? new SubjectVisit();
|
||||
await InsertInspection<PreviousSurgery>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
SiteId = subjectvisit.SiteId,
|
||||
SubjectVisitName = subjectvisit.VisitName,
|
||||
TrialId = subjectvisit.TrialId,
|
||||
|
@ -582,7 +488,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
subjectvisit = subjectvisit ?? new SubjectVisit();
|
||||
await InsertInspection<PreviousHistory>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
SiteId = subjectvisit.SiteId,
|
||||
SubjectVisitName = subjectvisit.VisitName,
|
||||
TrialId = subjectvisit.TrialId,
|
||||
|
@ -601,7 +506,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
subjectvisit = subjectvisit ?? new SubjectVisit();
|
||||
await InsertInspection<PreviousOther>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
SiteId = subjectvisit.SiteId,
|
||||
SubjectVisitName = subjectvisit.VisitName,
|
||||
TrialId = subjectvisit.TrialId,
|
||||
|
@ -626,7 +530,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
}
|
||||
await InsertInspection<QCChallenge>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
TrialId = x.TrialId,
|
||||
SubjectVisitId = x.SubjectVisitId,
|
||||
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 问题
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion)))
|
||||
{
|
||||
await InsertInspection<QCQuestion>(item.Entity as QCQuestion, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
});
|
||||
await InsertInspection<QCQuestion>(item.Entity as QCQuestion, type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 一致性核查文件
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile)))
|
||||
{
|
||||
await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
CreateTime = x.CreateTime,
|
||||
});
|
||||
}
|
||||
|
@ -791,24 +650,80 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
|
||||
}
|
||||
|
||||
#region 备注
|
||||
////Qc 问题答案
|
||||
//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
|
||||
//一致性核查 // 特殊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,
|
||||
});
|
||||
}
|
||||
|
||||
// 质疑信息 // 特殊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)))
|
||||
|
@ -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)))
|
||||
|
@ -866,10 +800,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
}
|
||||
|
||||
|
||||
await InsertInspection<ReadingPeriodSet>(item.Entity as ReadingPeriodSet, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
}, new
|
||||
await InsertInspection<ReadingPeriodSet>(item.Entity as ReadingPeriodSet, type, null, new
|
||||
{
|
||||
VisitName = visitName,
|
||||
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();
|
||||
await InsertInspection<ReadModule>(item.Entity as ReadModule, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
ObjectRelationParentId = entity.ReadingPeriodSetId,
|
||||
SubjectVisitId = x.SubjectVisitId,
|
||||
IsDistinctionInterface = false,
|
||||
|
@ -932,7 +862,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
|
||||
await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
SubjectVisitId = x.IsVisit ? x.ReadingId : null,
|
||||
}, new
|
||||
{
|
||||
|
@ -948,7 +877,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
|
||||
await InsertInspection<ReadingClinicalDataPDF>(item.Entity as ReadingClinicalDataPDF, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
SubjectId = x.SubjectId,
|
||||
IsDistinctionInterface = false,
|
||||
ObjectRelationParentId = entity.ReadingClinicalDataId
|
||||
|
@ -959,6 +887,11 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
@ -977,6 +910,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
|
||||
InspectionConvertDTO inspection = new InspectionConvertDTO();
|
||||
|
||||
|
||||
|
||||
if (expression != null)
|
||||
{
|
||||
var f = expression.Compile();
|
||||
|
@ -984,8 +919,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
inspection = f(entityObj);
|
||||
}
|
||||
|
||||
//避免重复赋值
|
||||
inspection.GeneralId = entityObj.Id;
|
||||
//避免重复赋值 有些特殊的GeneralId
|
||||
var generalId = (inspection.GeneralId != null && inspection.GeneralId != Guid.Empty) ? inspection.GeneralId : entityObj.Id ;
|
||||
inspection.GeneralId = generalId;
|
||||
|
||||
inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj, type, inspection.IsDistinctionInterface);
|
||||
|
||||
|
@ -1008,7 +944,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
#endregion
|
||||
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.IP = _userInfo.IP;
|
||||
|
@ -1309,177 +1245,177 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
|
||||
#region 待废弃 -by zhouhang 调整
|
||||
|
||||
/// <summary>
|
||||
/// 映射数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="mapData">要赋值的对象</param>
|
||||
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" };
|
||||
foreach (var item in column)
|
||||
{
|
||||
try
|
||||
{
|
||||
var i = mapData.GetType().GetProperty(item).GetValue(mapData);
|
||||
if (i == null || i == default(Guid))
|
||||
{
|
||||
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>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task AddInspectionRecordAsync<T>(T data, InspectionConvertDTO add, object otherItem = null) where T : class
|
||||
{
|
||||
//MapData(data, add);
|
||||
|
||||
MapEntityPropertyToAuditEntity(data, add);
|
||||
|
||||
InspectionGeneralData generalData = new InspectionGeneralData()
|
||||
{
|
||||
//CreateUserName = add.CreateUserName,
|
||||
SiteCode = add.SiteCode,
|
||||
SiteId = add.SiteId,
|
||||
//SiteName = add.SiteName,
|
||||
SubjectCode = add.SubjectCode,
|
||||
SubjectId = add.SubjectId,
|
||||
SubjectVisitId = add.SubjectVisitId,
|
||||
SubjectVisitName = add.SubjectVisitName,
|
||||
ResearchProgramNo = add.ResearchProgramNo,
|
||||
//RoleName = add.RoleName,
|
||||
TrialId = add.TrialId,
|
||||
TrialName = add.TrialName
|
||||
};
|
||||
|
||||
await SetInspectionNameValue(generalData);
|
||||
|
||||
#region 处理标识
|
||||
|
||||
var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == add.Identification);
|
||||
add.ObjectTypeId = from?.ObjectTypeId;
|
||||
add.OptTypeId = from?.OptTypeId;
|
||||
add.ChildrenTypeId = from?.ChildrenTypeId;
|
||||
add.ModuleTypeId = from?.ModuleTypeId;
|
||||
|
||||
#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.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
|
||||
}
|
||||
add.CreateUserId = _userInfo.Id;
|
||||
add.IP = _userInfo.IP;
|
||||
add.CreateTime = add.CreateTime == default(DateTime) ? DateTime.Now : add.CreateTime;
|
||||
|
||||
if (_userInfo.SignId != null)
|
||||
{
|
||||
add.SignId = _userInfo.SignId;
|
||||
add.IsSign = true;
|
||||
}
|
||||
|
||||
var inspectionData = new InspectionJsonDetail()
|
||||
{
|
||||
//稽查实体,加上扩充的信息
|
||||
Data = AddJsonItem(data, otherItem),
|
||||
|
||||
//通用信息
|
||||
CommonData = generalData
|
||||
};
|
||||
add.JsonDetail = inspectionData.ToJsonStr();
|
||||
add.BatchId = _userInfo.BatchId.Value;
|
||||
await _dbContext.DataInspection.AddAsync(add);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置项目以及名称
|
||||
/// </summary>
|
||||
/// <param name="generalData"></param>
|
||||
/// <returns></returns>
|
||||
public async Task SetInspectionNameValue(InspectionGeneralData generalData)
|
||||
{
|
||||
#region 项目名称
|
||||
|
||||
|
||||
if (generalData.TrialId != null)
|
||||
{
|
||||
|
||||
//项目添加哪里 直接会带信息过来,不用查询数据库 其他的地方需要查询数据库
|
||||
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();
|
||||
|
||||
generalData.ResearchProgramNo = trialdata.ResearchProgramNo;
|
||||
|
||||
generalData.TrialName = trialdata.ExperimentName;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 测试中心名称
|
||||
|
||||
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();
|
||||
|
||||
|
||||
//// 添加Site 哪里会带信息过来
|
||||
//if (string.IsNullOrEmpty(generalData.SiteName))
|
||||
///// <summary>
|
||||
///// 映射数据
|
||||
///// </summary>
|
||||
///// <param name="data"></param>
|
||||
///// <param name="mapData">要赋值的对象</param>
|
||||
//public void MapData(dynamic data, dynamic mapData)
|
||||
//{
|
||||
// generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
// List<string> column = new List<string>() { "TrialId", "SiteId", "SubjectId", "SubjectVisitId", "CreateUserName", "TrialName", "SiteName", "SubjectCode", "VisitName", "SubjectVisitName", "RoleName", "SiteCode", "ResearchProgramNo" };
|
||||
// foreach (var item in column)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var i = mapData.GetType().GetProperty(item).GetValue(mapData);
|
||||
// if (i == null || i == default(Guid))
|
||||
// {
|
||||
// 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>
|
||||
///// <exception cref="BusinessValidationFailedException"></exception>
|
||||
//public async Task AddInspectionRecordAsync<T>(T data, InspectionConvertDTO add, object otherItem = null) where T : class
|
||||
//{
|
||||
// //MapData(data, add);
|
||||
|
||||
// MapEntityPropertyToAuditEntity(data, add);
|
||||
|
||||
// InspectionGeneralData generalData = new InspectionGeneralData()
|
||||
// {
|
||||
// //CreateUserName = add.CreateUserName,
|
||||
// SiteCode = add.SiteCode,
|
||||
// SiteId = add.SiteId,
|
||||
// //SiteName = add.SiteName,
|
||||
// SubjectCode = add.SubjectCode,
|
||||
// SubjectId = add.SubjectId,
|
||||
// SubjectVisitId = add.SubjectVisitId,
|
||||
// SubjectVisitName = add.SubjectVisitName,
|
||||
// ResearchProgramNo = add.ResearchProgramNo,
|
||||
// //RoleName = add.RoleName,
|
||||
// TrialId = add.TrialId,
|
||||
// TrialName = add.TrialName
|
||||
// };
|
||||
|
||||
// await SetInspectionNameValue(generalData);
|
||||
|
||||
// #region 处理标识
|
||||
|
||||
// var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == add.Identification);
|
||||
// add.ObjectTypeId = from?.ObjectTypeId;
|
||||
// add.OptTypeId = from?.OptTypeId;
|
||||
// add.ChildrenTypeId = from?.ChildrenTypeId;
|
||||
// add.ModuleTypeId = from?.ModuleTypeId;
|
||||
|
||||
// #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.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
|
||||
// }
|
||||
// add.CreateUserId = _userInfo.Id;
|
||||
// add.IP = _userInfo.IP;
|
||||
// add.CreateTime = add.CreateTime == default(DateTime) ? DateTime.Now : add.CreateTime;
|
||||
|
||||
// if (_userInfo.SignId != null)
|
||||
// {
|
||||
// add.SignId = _userInfo.SignId;
|
||||
// add.IsSign = true;
|
||||
// }
|
||||
|
||||
// var inspectionData = new InspectionJsonDetail()
|
||||
// {
|
||||
// //稽查实体,加上扩充的信息
|
||||
// Data = AddJsonItem(data, otherItem),
|
||||
|
||||
// //通用信息
|
||||
// CommonData = generalData
|
||||
// };
|
||||
// add.JsonDetail = inspectionData.ToJsonStr();
|
||||
// add.BatchId = _userInfo.BatchId.Value;
|
||||
// await _dbContext.DataInspection.AddAsync(add);
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 受试者
|
||||
|
||||
if (generalData.SubjectId != null)
|
||||
{
|
||||
|
||||
// 添加Subject 哪里会带信息过来
|
||||
if (string.IsNullOrEmpty(generalData.SubjectCode))
|
||||
{
|
||||
generalData.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => x.Code).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 访视
|
||||
|
||||
if (generalData.SubjectVisitId != null)
|
||||
{
|
||||
//添加访视的时候,会带信息过来
|
||||
if (string.IsNullOrEmpty(generalData.SubjectVisitName))
|
||||
{
|
||||
generalData.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => x.VisitName).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
}
|
||||
}
|
||||
///// <summary>
|
||||
///// 设置项目以及名称
|
||||
///// </summary>
|
||||
///// <param name="generalData"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task SetInspectionNameValue(InspectionGeneralData generalData)
|
||||
//{
|
||||
// #region 项目名称
|
||||
|
||||
|
||||
#endregion
|
||||
// if (generalData.TrialId != null)
|
||||
// {
|
||||
|
||||
}
|
||||
// //项目添加哪里 直接会带信息过来,不用查询数据库 其他的地方需要查询数据库
|
||||
// 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();
|
||||
|
||||
// generalData.ResearchProgramNo = trialdata.ResearchProgramNo;
|
||||
|
||||
// generalData.TrialName = trialdata.ExperimentName;
|
||||
// }
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 测试中心名称
|
||||
|
||||
// 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();
|
||||
|
||||
|
||||
// //// 添加Site 哪里会带信息过来
|
||||
// //if (string.IsNullOrEmpty(generalData.SiteName))
|
||||
// //{
|
||||
// // generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
// //}
|
||||
// }
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 受试者
|
||||
|
||||
// if (generalData.SubjectId != null)
|
||||
// {
|
||||
|
||||
// // 添加Subject 哪里会带信息过来
|
||||
// if (string.IsNullOrEmpty(generalData.SubjectCode))
|
||||
// {
|
||||
// generalData.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => x.Code).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 访视
|
||||
|
||||
// if (generalData.SubjectVisitId != null)
|
||||
// {
|
||||
// //添加访视的时候,会带信息过来
|
||||
// if (string.IsNullOrEmpty(generalData.SubjectVisitName))
|
||||
// {
|
||||
// generalData.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => x.VisitName).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in New Issue