qc 问题稽查修改

Uat_Study
hang 2022-08-30 17:28:45 +08:00
parent b532ff775e
commit d5507e0570
8 changed files with 306 additions and 125 deletions

View File

@ -58,19 +58,5 @@ public static class ImageHelper
} }
static class IdentifierHelper
{
private static MD5 md5 = MD5.Create();
private static object lockObj = new object();
public static Guid CreateGuid(params string[] parts)
{
lock (lockObj)
{
return new Guid(md5.ComputeHash(Encoding.UTF8.GetBytes(string.Concat(parts))));
}
}
}

View File

@ -3628,6 +3628,12 @@
<param name="inDto"></param> <param name="inDto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculateService.GetLastVisitTaskId(IRaCIS.Core.Application.ViewModel.ReadingCalculateDto)">
<summary>
获取上一个访视任务Id
</summary>
<returns></returns>
</member>
<member name="T:IRaCIS.Core.Application.Service.ReadingMedicalReviewService"> <member name="T:IRaCIS.Core.Application.Service.ReadingMedicalReviewService">
<summary> <summary>
阅片医学审核 阅片医学审核
@ -7042,6 +7048,16 @@
IR影像阅片 IR影像阅片
</summary> </summary>
</member> </member>
<member name="M:IRaCIS.Application.Services.ReadingImageTaskService.GetTableAnswerRowInfoList(IRaCIS.Core.Application.Service.Reading.Dto.GetTableAnswerRowInfoInDto)">
<summary>
获取表格答案行信息
</summary>
<param name="inDto"></param>
<remarks>
(QuestionId) 可为空
</remarks>
<returns></returns>
</member>
<member name="M:IRaCIS.Application.Services.ReadingImageTaskService.GetReadingQuestionAndAnswer(IRaCIS.Core.Application.Service.Reading.Dto.GetReadingQuestionAndAnswerInDto)"> <member name="M:IRaCIS.Application.Services.ReadingImageTaskService.GetReadingQuestionAndAnswer(IRaCIS.Core.Application.Service.Reading.Dto.GetReadingQuestionAndAnswerInDto)">
<summary> <summary>
获取表格问题及答案2022-08-26 获取表格问题及答案2022-08-26

View File

@ -6,6 +6,7 @@ using IRaCIS.Core.Application.Services;
using EasyCaching.Core; using EasyCaching.Core;
using System.Linq.Expressions; using System.Linq.Expressions;
using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Infrastructure;
namespace IRaCIS.Core.Application.Service.ImageAndDoc namespace IRaCIS.Core.Application.Service.ImageAndDoc
{ {

View File

@ -121,15 +121,17 @@ namespace IRaCIS.Application.Services
} }
if (inDto.ReadingCategorys.Count > 0) //if (inDto.ReadingCategorys.Count > 0)
{ //{
await _enrollReadingCategoryRepository.BatchDeleteNoTrackingAsync(x => x.EnrollId == inDto.EnrollId); // await _enrollReadingCategoryRepository.BatchDeleteNoTrackingAsync(x => x.EnrollId == inDto.EnrollId);
//}
//else
//{
// await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId);
//}
}
else
{
await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId); await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId);
}
List<EnrollReadingCategory> enrollReadings = inDto.ReadingCategorys.Select(x => new EnrollReadingCategory() List<EnrollReadingCategory> enrollReadings = inDto.ReadingCategorys.Select(x => new EnrollReadingCategory()

View File

@ -51,27 +51,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
_userInfo.BatchId = _userInfo.BatchId == null ? NewId.NextGuid() : _userInfo.BatchId; _userInfo.BatchId = _userInfo.BatchId == null ? NewId.NextGuid() : _userInfo.BatchId;
} }
/// <summary>
/// 传入实体对象
/// </summary>
public async Task IncomingEntitys(List<EntityEntry> entitys)
{
// 修改
await InsertAddEntitys(
entitys.Where(x => x.State == EntityState.Modified &&
(!typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) || !(bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) || NodeleteTableTypes.Contains(x.Entity.GetType()))
).ToList(), AuditOpt.Update);
// 新增
await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), AuditOpt.Add);
// 删除
await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted
|| (typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) && (bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) && x.State == EntityState.Modified && !NodeleteTableTypes.Contains(x.Entity.GetType()))
).ToList(), AuditOpt.Deleted);
}
/// <summary> /// <summary>
/// 特殊删除 /// 特殊删除
@ -91,11 +71,36 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
} }
public string GetEntityAuditOpt(EntityEntry entityEntry)
{
if (entityEntry.State == EntityState.Added)
{
return AuditOpt.Add;
}
else if (entityEntry.State == EntityState.Deleted ||
(entityEntry.State == EntityState.Modified
&& typeof(ISoftDelete).IsAssignableFrom(entityEntry.Entity.GetType())
&& (bool)entityEntry.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(entityEntry.Entity)
&& entityEntry.State == EntityState.Modified
&& !NodeleteTableTypes.Contains(entityEntry.Entity.GetType())
)
)
{
return AuditOpt.Deleted;
}
else
{
return AuditOpt.Update;
}
}
/// <summary> /// <summary>
/// 插入Add的实体 /// 插入Add的实体
/// </summary> /// </summary>
/// <param name="entitys"></param> /// <param name="entitys"></param>
public async Task InsertAddEntitys(List<EntityEntry> entitys, string type) public async Task InsertAddEntitys(List<EntityEntry> entitys)
{ {
#region 区分 #region 区分
@ -104,6 +109,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as Trial; var entity = item.Entity as Trial;
List<string> trialDics = new List<string>(); List<string> trialDics = new List<string>();
var dictionaryIds = new List<Guid>(); var dictionaryIds = new List<Guid>();
@ -131,6 +138,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 系统文件签署 父层级未记录稽查(系统文档初始数据) // 系统文件签署 父层级未记录稽查(系统文档初始数据)
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocConfirmedUser))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocConfirmedUser)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SystemDocConfirmedUser; var entity = item.Entity as SystemDocConfirmedUser;
var systemDocument = await _dbContext.SystemDocument.Where(x => x.Id == entity.SystemDocumentId).FirstOrDefaultAsync(); var systemDocument = await _dbContext.SystemDocument.Where(x => x.Id == entity.SystemDocumentId).FirstOrDefaultAsync();
await InsertInspection<SystemDocConfirmedUser>(entity, type, x => new InspectionConvertDTO() await InsertInspection<SystemDocConfirmedUser>(entity, type, x => new InspectionConvertDTO()
@ -155,6 +164,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目文件签署 // 项目文件签署
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocUserTypeConfirmedUser))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocUserTypeConfirmedUser)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialDocUserTypeConfirmedUser; var entity = item.Entity as TrialDocUserTypeConfirmedUser;
var trialDoc = await _dbContext.TrialDocument.Where(x => x.Id == entity.TrialDocumentId).FirstOrDefaultAsync(); var trialDoc = await _dbContext.TrialDocument.Where(x => x.Id == entity.TrialDocumentId).FirstOrDefaultAsync();
@ -180,74 +191,118 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// Qc 问题答案
// Qc 问题答案 // 特殊GeneralId
if (entitys.Any(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer))) if (entitys.Any(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)))
{ {
var entitylist = entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)).Select(x => x.Entity as TrialQCQuestionAnswer).ToList(); var entityEntryList = entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer));
var firstEntity = entitylist.FirstOrDefault();
var subjectVisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstEntity.SubjectVisitId).FirstOrDefaultAsync(); var type = entityEntryList.All(t => t.State == EntityState.Added) ? AuditOpt.Add : AuditOpt.Update;
subjectVisit = subjectVisit ?? new SubjectVisit();
if (type == "Add")
{
await InsertInspection(firstEntity, type, answer => new InspectionConvertDTO() var list = entityEntryList.Select(t => t.Entity as TrialQCQuestionAnswer);
var firstEntity = list.FirstOrDefault();
var trialQuestionIdList = list.Select(t => t.TrialQCQuestionConfigureId);
var trialQuestionNameList = await _dbContext.TrialQCQuestionConfigure.Where(x => x.TrialId==firstEntity.TrialId).Select(t => new { t.QuestionName , TrialQCQuestionConfigureId = t.Id,t.ShowOrder} ).ToListAsync();
var beforeAnswerList = await _dbContext.TrialQCQuestionAnswer.Where(x => x.SubjectVisitId == firstEntity.SubjectVisitId && x.CurrentQCEnum == firstEntity.CurrentQCEnum && x.QCProcessEnum == firstEntity.QCProcessEnum)
.Select(u => new { u.TrialQCQuestionConfigureId, u.Answer }).ToListAsync();
var answerList = list.Select(u => new { u.TrialQCQuestionConfigureId, u.Answer }).Union(beforeAnswerList).DistinctBy(t => t.TrialQCQuestionConfigureId);
var cloneEntity = firstEntity.Clone();
//保证Id 唯一
cloneEntity.Id = IdentifierHelper.CreateGuid(firstEntity.SubjectVisitId.ToString(), ((int)firstEntity.QCProcessEnum).ToString(), ((int)firstEntity.CurrentQCEnum).ToString());
await InsertInspection(cloneEntity, type, x => new InspectionConvertDTO()
{ {
SiteId = subjectVisit.SiteId, SubjectVisitId = x.SubjectVisitId,
SubjectId = subjectVisit.SubjectId,
SubjectVisitName = subjectVisit.VisitName,
TrialId = subjectVisit.TrialId,
SubjectVisitId = subjectVisit.Id,
GeneralId = subjectVisit.Id,
//byzhouhang //byzhouhang
ObjectRelationParentId = subjectVisit.Id, ObjectRelationParentId = x.SubjectVisitId,
}, new }, new
{ {
QcQuestionAnswerCommands = await Getdata(entitylist), QcQuestionAnswerList = answerList.Join(trialQuestionNameList, t=>t.TrialQCQuestionConfigureId,u=>u.TrialQCQuestionConfigureId,(t,u)=>new {t.Answer,u.QuestionName,u.ShowOrder}).OrderBy(t=>t.ShowOrder).ToList(),
});
}
else if (type == "Update")
{
var questionIds = entitylist.Where(x => x.SubjectVisitId == subjectVisit.Id).Select(x => x.Id).ToList();
var createUserId = entitylist.Select(x => x.CreateUserId).FirstOrDefault();
var noUpdateData = _dbContext.TrialQCQuestionAnswer.Where(x => x.CreateUserId == createUserId && x.SubjectVisitId == subjectVisit.Id && !questionIds.Contains(x.Id)).ToList();
entitylist.AddRange(noUpdateData);
await InsertInspection(firstEntity, type, answer => new InspectionConvertDTO()
{
SiteId = subjectVisit.SiteId,
SubjectId = subjectVisit.SubjectId,
SubjectVisitName = subjectVisit.VisitName,
TrialId = subjectVisit.TrialId,
SubjectVisitId = subjectVisit.Id,
GeneralId = subjectVisit.Id,
//byzhouhang
ObjectRelationParentId = subjectVisit.Id,
}, new
{
QcQuestionAnswerCommands = await Getdata(entitylist),
}); });
}
async Task<List<AnswerDto>> Getdata(List<TrialQCQuestionAnswer> questionAnswers)
{ #region OLd
var ids = questionAnswers.Select(x => x.TrialQCQuestionConfigureId).ToList(); //var entitylist = entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)).Select(x => x.Entity as TrialQCQuestionAnswer).ToList();
var trialQCQuestionConfigureDatas = await _dbContext.TrialQCQuestionConfigure.Where(x => ids.Contains(x.Id)).ToListAsync(); //var firstEntity = entitylist.FirstOrDefault();
var collect = questionAnswers.GroupJoin(trialQCQuestionConfigureDatas, one => one.TrialQCQuestionConfigureId, two => two.Id, (x, y) => new { one = x, two = y }) //var subjectVisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstEntity.SubjectVisitId).FirstOrDefaultAsync();
.SelectMany(a => a.two.DefaultIfEmpty(), (c, d) => new { c = c.one, d }) //subjectVisit = subjectVisit ?? new SubjectVisit();
.OrderBy(x => x.d.ShowOrder) //if (type == "Add")
.Select(o => new AnswerDto() //{
{
QuestionName = o.d.QuestionName,
Answer = o.c.Answer, // await InsertInspection(firstEntity, type, answer => new InspectionConvertDTO()
}).ToList(); // {
return collect; // SiteId = subjectVisit.SiteId,
} // SubjectId = subjectVisit.SubjectId,
// SubjectVisitName = subjectVisit.VisitName,
// TrialId = subjectVisit.TrialId,
// SubjectVisitId = subjectVisit.Id,
// //GeneralId = subjectVisit.Id,
// //byzhouhang
// ObjectRelationParentId = subjectVisit.Id,
// }, new
// {
// QcQuestionAnswerCommands = await Getdata(entitylist),
// });
//}
//else if (type == "Update")
//{
// var questionIds = entitylist.Where(x => x.SubjectVisitId == subjectVisit.Id).Select(x => x.Id).ToList();
// var createUserId = entitylist.Select(x => x.CreateUserId).FirstOrDefault();
// var noUpdateData = _dbContext.TrialQCQuestionAnswer.Where(x => x.CreateUserId == createUserId && x.SubjectVisitId == subjectVisit.Id && !questionIds.Contains(x.Id)).ToList();
// entitylist.AddRange(noUpdateData);
// await InsertInspection(firstEntity, type, answer => new InspectionConvertDTO()
// {
// SiteId = subjectVisit.SiteId,
// SubjectId = subjectVisit.SubjectId,
// SubjectVisitName = subjectVisit.VisitName,
// TrialId = subjectVisit.TrialId,
// SubjectVisitId = subjectVisit.Id,
// //GeneralId = subjectVisit.Id,
// //byzhouhang
// ObjectRelationParentId = subjectVisit.Id,
// }, new
// {
// QcQuestionAnswerCommands = await Getdata(entitylist),
// });
//}
//async Task<List<AnswerDto>> Getdata(List<TrialQCQuestionAnswer> questionAnswers)
//{
// var ids = questionAnswers.Select(x => x.TrialQCQuestionConfigureId).ToList();
// var trialQCQuestionConfigureDatas = await _dbContext.TrialQCQuestionConfigure.Where(x => ids.Contains(x.Id)).ToListAsync();
// var collect = questionAnswers.GroupJoin(trialQCQuestionConfigureDatas, one => one.TrialQCQuestionConfigureId, two => two.Id, (x, y) => new { one = x, two = y })
// .SelectMany(a => a.two.DefaultIfEmpty(), (c, d) => new { c = c.one, d })
// .OrderBy(x => x.d.ShowOrder)
// .Select(o => new AnswerDto()
// {
// QuestionName = o.d.QuestionName,
// Answer = o.c.Answer,
// }).ToList();
// return collect;
//}
#endregion
} }
@ -262,6 +317,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//QC 质疑 //QC 质疑
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as QCChallenge; var entity = item.Entity as QCChallenge;
await InsertInspection<QCChallenge>(entity, type, x => new InspectionConvertDTO() await InsertInspection<QCChallenge>(entity, type, x => new InspectionConvertDTO()
@ -279,6 +336,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 质疑 对话 // 质疑 对话
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallengeDialog))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallengeDialog)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as QCChallengeDialog; var entity = item.Entity as QCChallengeDialog;
await InsertInspection<QCChallengeDialog>(entity, type, x => new InspectionConvertDTO() await InsertInspection<QCChallengeDialog>(entity, type, x => new InspectionConvertDTO()
@ -297,6 +356,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//一致性核查 对话 //一致性核查 对话
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as CheckChallengeDialog; var entity = item.Entity as CheckChallengeDialog;
//var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); //var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
@ -332,6 +392,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 一致性核查文件 是否需要单独一个表记录? // 一致性核查文件 是否需要单独一个表记录?
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile)))
{ {
var type = GetEntityAuditOpt(item);
await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO() await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO()
{ {
ObjectRelationParentId = x.TrialId ObjectRelationParentId = x.TrialId
@ -342,6 +404,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 中心调研表 // 中心调研表
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteSurvey))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteSurvey)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialSiteSurvey; var entity = item.Entity as TrialSiteSurvey;
if (entity.TrialSite == null) if (entity.TrialSite == null)
{ {
@ -381,6 +445,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 既往手术史 // 既往手术史
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousSurgery))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousSurgery)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as PreviousSurgery; var entity = item.Entity as PreviousSurgery;
await InsertInspection<PreviousSurgery>(entity, type, x => new InspectionConvertDTO() await InsertInspection<PreviousSurgery>(entity, type, x => new InspectionConvertDTO()
@ -402,6 +468,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 既往放疗史 // 既往放疗史
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousHistory))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousHistory)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as PreviousHistory; var entity = item.Entity as PreviousHistory;
await InsertInspection<PreviousHistory>(entity, type, x => new InspectionConvertDTO() await InsertInspection<PreviousHistory>(entity, type, x => new InspectionConvertDTO()
@ -424,6 +493,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 其他治疗史 // 其他治疗史
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousOther))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousOther)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as PreviousOther; var entity = item.Entity as PreviousOther;
await InsertInspection<PreviousOther>(entity, type, x => new InspectionConvertDTO() await InsertInspection<PreviousOther>(entity, type, x => new InspectionConvertDTO()
@ -449,6 +520,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//系统文件 //系统文件
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocument))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocument)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SystemDocument; var entity = item.Entity as SystemDocument;
List<Guid> needConfirmedUserTypeIdList = new List<Guid>(); List<Guid> needConfirmedUserTypeIdList = new List<Guid>();
@ -477,6 +550,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目文档 // 项目文档
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocument))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocument)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialDocument; var entity = item.Entity as TrialDocument;
@ -509,6 +583,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//系统 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)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as QCQuestion; var entity = item.Entity as QCQuestion;
var parentQuestionName = await _dbContext.QCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync(); var parentQuestionName = await _dbContext.QCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync();
@ -523,6 +599,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目QC问题 // 项目QC问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestion))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestion)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialQCQuestion; var entity = item.Entity as TrialQCQuestion;
var parentQuestionName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync(); var parentQuestionName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync();
@ -540,6 +619,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//系统 医学审核问题 //系统 医学审核问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingMedicineSystemQuestion))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingMedicineSystemQuestion)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingMedicineSystemQuestion; var entity = item.Entity as ReadingMedicineSystemQuestion;
var parentQuestionName = string.Empty; var parentQuestionName = string.Empty;
@ -557,6 +638,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//项目医学审核问题 //项目医学审核问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingMedicineTrialQuestion))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingMedicineTrialQuestion)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingMedicineTrialQuestion; var entity = item.Entity as ReadingMedicineTrialQuestion;
var parentQuestionName = string.Empty; var parentQuestionName = string.Empty;
@ -577,6 +660,8 @@ 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)))
{ {
var type = GetEntityAuditOpt(item);
await InsertInspection<SystemBasicData>(item.Entity as SystemBasicData, type, x => new InspectionConvertDTO() await InsertInspection<SystemBasicData>(item.Entity as SystemBasicData, type, x => new InspectionConvertDTO()
{ {
IsDistinctionInterface = false IsDistinctionInterface = false
@ -588,6 +673,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目中心 Site未稽查 // 项目中心 Site未稽查
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSite))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSite)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialSite; var entity = item.Entity as TrialSite;
if (entity.Site == null) if (entity.Site == null)
{ {
@ -615,6 +702,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目人员 // 项目人员
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialUser; var entity = item.Entity as TrialUser;
//var user = await _dbContext.Users.Include(x => x.UserTypeRole).FirstOrDefaultAsync(x => x.Id == entity.UserId); //var user = await _dbContext.Users.Include(x => x.UserTypeRole).FirstOrDefaultAsync(x => x.Id == entity.UserId);
@ -630,6 +718,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目中心人员 // 项目中心人员
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteUser))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteUser)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialSiteUser; var entity = item.Entity as TrialSiteUser;
@ -650,6 +741,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 受试者 // 受试者
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as 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(); var finalSubjectVisitName = await _dbContext.SubjectVisit.AsNoTracking().Where(x => x.Id == entity.FinalSubjectVisitId && entity.FinalSubjectVisitId != null).Select(x => x.VisitName).FirstOrDefaultAsync();
@ -676,6 +769,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 访视计划 // 访视计划
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as VisitStage; var entity = item.Entity as VisitStage;
await InsertInspection<VisitStage>(item.Entity as VisitStage, type, x => new InspectionConvertDTO() await InsertInspection<VisitStage>(item.Entity as VisitStage, type, x => new InspectionConvertDTO()
@ -705,6 +801,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 访视 // 访视
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SubjectVisit; var entity = item.Entity as SubjectVisit;
await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO() await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO()
@ -725,6 +824,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// Dicom // Dicom
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy)))
{ {
var type = GetEntityAuditOpt(item);
await InsertInspection<DicomStudy>(item.Entity as DicomStudy, type, x => new InspectionConvertDTO() await InsertInspection<DicomStudy>(item.Entity as DicomStudy, type, x => new InspectionConvertDTO()
{ {
ObjectRelationParentId = x.SubjectVisitId ObjectRelationParentId = x.SubjectVisitId
@ -734,6 +835,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 序列 // 序列
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomSeries))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomSeries)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as DicomSeries; var entity = item.Entity as DicomSeries;
await InsertInspection<DicomSeries>(item.Entity as DicomSeries, type, x => new InspectionConvertDTO() await InsertInspection<DicomSeries>(item.Entity as DicomSeries, type, x => new InspectionConvertDTO()
@ -747,6 +850,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 非Dicom // 非Dicom
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudy))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudy)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as NoneDicomStudy; var entity = item.Entity as NoneDicomStudy;
await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new InspectionConvertDTO() await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new InspectionConvertDTO()
@ -789,6 +895,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//阅片人入组 父层级未记录稽查(医生) //阅片人入组 父层级未记录稽查(医生)
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as Enroll; var entity = item.Entity as Enroll;
var doctor = await _dbContext.Doctor.FirstOrDefaultAsync(x => x.Id == entity.DoctorId); var doctor = await _dbContext.Doctor.FirstOrDefaultAsync(x => x.Id == entity.DoctorId);
@ -813,9 +920,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common
if (entitys.Any(x => x.Entity.GetType() == typeof(EnrollReadingCategory))) if (entitys.Any(x => x.Entity.GetType() == typeof(EnrollReadingCategory)))
{ {
var list = entitys.Where(x => x.Entity.GetType() == typeof(EnrollReadingCategory)).Select(t => t.Entity as EnrollReadingCategory).ToList(); var type = AuditOpt.Update;
var first = list.FirstOrDefault(); var addList = entitys.Where(x => x.Entity.GetType() == typeof(EnrollReadingCategory) && x.State == EntityState.Added).Select(t => t.Entity as EnrollReadingCategory).ToList();
var deleteList = entitys.Where(x => x.Entity.GetType() == typeof(EnrollReadingCategory) && x.State == EntityState.Added).Select(t => t.Entity as EnrollReadingCategory).ToList();
var first = addList.Union(deleteList).FirstOrDefault();
var enrollId = first.EnrollId; var enrollId = first.EnrollId;
@ -843,7 +953,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
//子层级只需要记录自己这边的信息就好了 只有删除 和添加 没有更新(如果是删除,再添加,删除不会走稽查逻辑,业务代码已控制) //子层级只需要记录自己这边的信息就好了 只有删除 和添加 没有更新(如果是删除,再添加,删除不会走稽查逻辑,业务代码已控制)
ReadingCategoryList = type == AuditOpt.Deleted ? null : list.Select(t => t.ReadingCategory).ToList(), ReadingCategoryList = addList.Select(t => t.ReadingCategory).ToList(),
}); });
} }
@ -858,6 +968,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ClinicalDataSystemSet))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ClinicalDataSystemSet)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ClinicalDataSystemSet; var entity = item.Entity as ClinicalDataSystemSet;
await InsertInspection<ClinicalDataSystemSet>(entity, type, x => new InspectionConvertDTO() await InsertInspection<ClinicalDataSystemSet>(entity, type, x => new InspectionConvertDTO()
@ -871,6 +983,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//项目临床数据配置 //项目临床数据配置
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ClinicalDataTrialSet))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ClinicalDataTrialSet)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ClinicalDataTrialSet; var entity = item.Entity as ClinicalDataTrialSet;
await InsertInspection<ClinicalDataTrialSet>(entity, type, x => new InspectionConvertDTO() await InsertInspection<ClinicalDataTrialSet>(entity, type, x => new InspectionConvertDTO()
@ -883,6 +997,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// CRC PM 临床数据 // CRC PM 临床数据
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingClinicalData))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingClinicalData)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingClinicalData; var entity = item.Entity as ReadingClinicalData;
await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO() await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO()
@ -899,6 +1015,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//阅片期计划 //阅片期计划
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingPeriodSet))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingPeriodSet)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingPeriodSet; var entity = item.Entity as ReadingPeriodSet;
var siteCodes = string.Empty; var siteCodes = string.Empty;
@ -948,6 +1066,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//阅片期 //阅片期
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadModule))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadModule)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadModule; var entity = item.Entity as ReadModule;
await InsertInspection<ReadModule>(item.Entity as ReadModule, type, x => new InspectionConvertDTO() await InsertInspection<ReadModule>(item.Entity as ReadModule, type, x => new InspectionConvertDTO()
@ -968,6 +1088,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//用户添加 //用户添加
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(User))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(User)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as User; var entity = item.Entity as User;
await InsertInspection<User>(entity, type, x => new InspectionConvertDTO() await InsertInspection<User>(entity, type, x => new InspectionConvertDTO()
@ -985,6 +1107,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//分配规则 //分配规则
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskAllocationRule))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskAllocationRule)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TaskAllocationRule; var entity = item.Entity as TaskAllocationRule;
await InsertInspection<TaskAllocationRule>(entity, type, x => new InspectionConvertDTO() await InsertInspection<TaskAllocationRule>(entity, type, x => new InspectionConvertDTO()
@ -1001,6 +1125,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// suject 医生绑定关系 // suject 医生绑定关系
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectUser))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectUser)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SubjectUser; var entity = item.Entity as SubjectUser;
await InsertInspection<SubjectUser>(entity, type, x => new InspectionConvertDTO() await InsertInspection<SubjectUser>(entity, type, x => new InspectionConvertDTO()
@ -1017,6 +1143,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//任务 //任务
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitTask))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitTask)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as VisitTask; var entity = item.Entity as VisitTask;
await InsertInspection<VisitTask>(entity, type, x => new InspectionConvertDTO() await InsertInspection<VisitTask>(entity, type, x => new InspectionConvertDTO()
@ -1035,6 +1163,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//申请重阅记录表 //申请重阅记录表
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitTaskReReading))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitTaskReReading)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as VisitTaskReReading; var entity = item.Entity as VisitTaskReReading;
await InsertInspection<VisitTaskReReading>(entity, type, x => new InspectionConvertDTO() await InsertInspection<VisitTaskReReading>(entity, type, x => new InspectionConvertDTO()
@ -1053,6 +1183,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//医学审核 //医学审核
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskMedicalReview))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskMedicalReview)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TaskMedicalReview; var entity = item.Entity as TaskMedicalReview;
await InsertInspection<TaskMedicalReview>(entity, type, x => new InspectionConvertDTO() await InsertInspection<TaskMedicalReview>(entity, type, x => new InspectionConvertDTO()
@ -1069,6 +1201,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskConsistentRule))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskConsistentRule)))
{ {
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TaskConsistentRule; var entity = item.Entity as TaskConsistentRule;
await InsertInspection<TaskConsistentRule>(entity, type, x => new InspectionConvertDTO() await InsertInspection<TaskConsistentRule>(entity, type, x => new InspectionConvertDTO()
@ -1321,14 +1455,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
entityTypeName = "New/" + "UserSigned"; entityTypeName = "New/" + "UserSigned";
} }
object entity;
switch (entityObj.GetType().Name) switch (entityObj.GetType().Name)
{ {
//case nameof(QCChallengeDialog):
//case nameof(QCChallenge):
//case nameof(CheckChallengeDialog):
// type = type + "/(" + _userInfo.UserTypeShortName + ")";
// break;
case nameof(SystemBasicData): case nameof(SystemBasicData):
@ -1618,6 +1746,28 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#region 待废弃 -by zhouhang 调整 #region 待废弃 -by zhouhang 调整
///// <summary>
///// 传入实体对象
///// </summary>
//public async Task IncomingEntitys(List<EntityEntry> entitys)
//{
// // 修改
// await InsertAddEntitys(
// entitys.Where(x => x.State == EntityState.Modified &&
// (!typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) || !(bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) || NodeleteTableTypes.Contains(x.Entity.GetType()))
// ).ToList(), AuditOpt.Update);
// // 新增
// await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), AuditOpt.Add);
// // 删除
// await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted
// || (typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) && (bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) && x.State == EntityState.Modified && !NodeleteTableTypes.Contains(x.Entity.GetType()))
// ).ToList(), AuditOpt.Deleted);
//}
//// 非Dicom文件 //// 非Dicom文件
//if (entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) //if (entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
//{ //{

View File

@ -9,6 +9,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
public interface IAuditingData public interface IAuditingData
{ {
Task IncomingEntitys(List<EntityEntry> entitys); //Task IncomingEntitys(List<EntityEntry> entitys);
Task InsertAddEntitys(List<EntityEntry> entitys);
} }
} }

View File

@ -481,7 +481,9 @@ namespace IRaCIS.Core.Infra.EFCore
.ToList(); .ToList();
AuditingData auditingData = new AuditingData(this, _userInfo); AuditingData auditingData = new AuditingData(this, _userInfo);
await auditingData.IncomingEntitys(entities); //await auditingData.IncomingEntitys(entities);
await auditingData.InsertAddEntitys(entities);
//} //}
//catch (Exception) //catch (Exception)
//{ //{

View File

@ -0,0 +1,22 @@
using System;
using System.Security.Cryptography;
using System.Text;
namespace IRaCIS.Core.Infrastructure
{
public static class IdentifierHelper
{
private static MD5 md5 = MD5.Create();
private static object lockObj = new object();
public static Guid CreateGuid(params string[] parts)
{
lock (lockObj)
{
return new Guid(md5.ComputeHash(Encoding.UTF8.GetBytes(string.Concat(parts))));
}
}
}
}