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>
<returns></returns>
</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">
<summary>
阅片医学审核
@ -7042,6 +7048,16 @@
IR影像阅片
</summary>
</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)">
<summary>
获取表格问题及答案2022-08-26

View File

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

View File

@ -121,15 +121,17 @@ namespace IRaCIS.Application.Services
}
if (inDto.ReadingCategorys.Count > 0)
{
await _enrollReadingCategoryRepository.BatchDeleteNoTrackingAsync(x => x.EnrollId == inDto.EnrollId);
//if (inDto.ReadingCategorys.Count > 0)
//{
// 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);
}
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;
}
/// <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>
/// 特殊删除
@ -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>
/// 插入Add的实体
/// </summary>
/// <param name="entitys"></param>
public async Task InsertAddEntitys(List<EntityEntry> entitys, string type)
public async Task InsertAddEntitys(List<EntityEntry> entitys)
{
#region 区分
@ -104,6 +109,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as Trial;
List<string> trialDics = new List<string>();
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SystemDocConfirmedUser;
var systemDocument = await _dbContext.SystemDocument.Where(x => x.Id == entity.SystemDocumentId).FirstOrDefaultAsync();
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialDocUserTypeConfirmedUser;
var trialDoc = await _dbContext.TrialDocument.Where(x => x.Id == entity.TrialDocumentId).FirstOrDefaultAsync();
@ -171,8 +182,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
UploadTime = trialDoc.CreateTime,
CreateUserName = _userInfo.UserName,
UserType=_userInfo.UserTypeShortName,
IsSigned =true
UserType = _userInfo.UserTypeShortName,
IsSigned = true
});
}
@ -180,74 +191,118 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// Qc 问题答案 // 特殊GeneralId
// Qc 问题答案
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 firstEntity = entitylist.FirstOrDefault();
var subjectVisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstEntity.SubjectVisitId).FirstOrDefaultAsync();
subjectVisit = subjectVisit ?? new SubjectVisit();
if (type == "Add")
{
var entityEntryList = entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer));
var type = entityEntryList.All(t => t.State == EntityState.Added) ? AuditOpt.Add : AuditOpt.Update;
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,
SubjectId = subjectVisit.SubjectId,
SubjectVisitName = subjectVisit.VisitName,
TrialId = subjectVisit.TrialId,
SubjectVisitId = subjectVisit.Id,
GeneralId = subjectVisit.Id,
SubjectVisitId = x.SubjectVisitId,
//byzhouhang
ObjectRelationParentId = subjectVisit.Id,
ObjectRelationParentId = x.SubjectVisitId,
}, 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),
QcQuestionAnswerList = answerList.Join(trialQuestionNameList, t=>t.TrialQCQuestionConfigureId,u=>u.TrialQCQuestionConfigureId,(t,u)=>new {t.Answer,u.QuestionName,u.ShowOrder}).OrderBy(t=>t.ShowOrder).ToList(),
});
}
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;
}
#region OLd
//var entitylist = entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)).Select(x => x.Entity as TrialQCQuestionAnswer).ToList();
//var firstEntity = entitylist.FirstOrDefault();
//var subjectVisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstEntity.SubjectVisitId).FirstOrDefaultAsync();
//subjectVisit = subjectVisit ?? new SubjectVisit();
//if (type == "Add")
//{
// 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),
// });
//}
//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 质疑
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as QCChallenge;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as QCChallengeDialog;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as CheckChallengeDialog;
//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)))
{
var type = GetEntityAuditOpt(item);
await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO()
{
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialSiteSurvey;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as PreviousSurgery;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as PreviousHistory;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as PreviousOther;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SystemDocument;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialDocument;
@ -495,7 +569,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var usertypeName = string.Join(",", usertypeNames);
await InsertInspection<TrialDocument>(entity, type, x => new InspectionConvertDTO()
{
IsDistinctionInterface=true,
IsDistinctionInterface = true,
ObjectRelationParentId = x.TrialId
},
new
@ -509,6 +583,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//系统 Qc 问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as QCQuestion;
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问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestion)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialQCQuestion;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingMedicineSystemQuestion;
var parentQuestionName = string.Empty;
@ -551,12 +632,14 @@ namespace IRaCIS.Core.Infra.EFCore.Common
await InsertInspection<ReadingMedicineSystemQuestion>(entity, type, x => new InspectionConvertDTO()
{
IsDistinctionInterface = false,
},new { ParentQuestionName = parentQuestionName });
}, new { ParentQuestionName = parentQuestionName });
}
//项目医学审核问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingMedicineTrialQuestion)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingMedicineTrialQuestion;
var parentQuestionName = string.Empty;
@ -577,9 +660,11 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 签名模板
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()
{
IsDistinctionInterface=false
IsDistinctionInterface = false
});
}
@ -588,6 +673,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 项目中心 Site未稽查
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSite)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialSite;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TrialUser;
//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)))
{
var type = GetEntityAuditOpt(item);
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)))
{
var type = GetEntityAuditOpt(item);
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();
@ -676,6 +769,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 访视计划
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as VisitStage;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SubjectVisit;
await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO()
@ -725,6 +824,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// Dicom
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()
{
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as DicomSeries;
await InsertInspection<DicomSeries>(item.Entity as DicomSeries, type, x => new InspectionConvertDTO()
@ -747,6 +850,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 非Dicom
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudy)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as NoneDicomStudy;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as Enroll;
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)))
{
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;
@ -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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ClinicalDataSystemSet;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ClinicalDataTrialSet;
await InsertInspection<ClinicalDataTrialSet>(entity, type, x => new InspectionConvertDTO()
@ -883,6 +997,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// CRC PM 临床数据
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingClinicalData)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingClinicalData;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadingPeriodSet;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as ReadModule;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as User;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TaskAllocationRule;
await InsertInspection<TaskAllocationRule>(entity, type, x => new InspectionConvertDTO()
@ -1001,6 +1125,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// suject 医生绑定关系
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectUser)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as SubjectUser;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as VisitTask;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as VisitTaskReReading;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TaskMedicalReview;
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)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as TaskConsistentRule;
await InsertInspection<TaskConsistentRule>(entity, type, x => new InspectionConvertDTO()
@ -1321,14 +1455,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
entityTypeName = "New/" + "UserSigned";
}
object entity;
switch (entityObj.GetType().Name)
{
//case nameof(QCChallengeDialog):
//case nameof(QCChallenge):
//case nameof(CheckChallengeDialog):
// type = type + "/(" + _userInfo.UserTypeShortName + ")";
// break;
case nameof(SystemBasicData):
@ -1374,7 +1502,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
case nameof(QCChallengeDialog):
type = type + "/(" + _userInfo.UserTypeShortName + ")";
var dialog= entityObj as QCChallengeDialog;
var dialog = entityObj as QCChallengeDialog;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closeqcchallenge":
@ -1424,7 +1552,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break;
}
if(sv.CheckChallengeState==CheckChanllengeTypeEnum.CRCWaitPMReply|| sv.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply)
if (sv.CheckChallengeState == CheckChanllengeTypeEnum.CRCWaitPMReply || sv.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply)
{
//发送对话 修改质疑状态 不需要区分接口
IsDistinctionInterface = false;
@ -1618,6 +1746,28 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#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文件
//if (entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
//{

View File

@ -9,6 +9,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
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();
AuditingData auditingData = new AuditingData(this, _userInfo);
await auditingData.IncomingEntitys(entities);
//await auditingData.IncomingEntitys(entities);
await auditingData.InsertAddEntitys(entities);
//}
//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))));
}
}
}
}