diff --git a/IRaCIS.Core.Domain/Common/SystemBasicData.cs b/IRaCIS.Core.Domain/Common/SystemBasicData.cs index c44b14681..8e08470fa 100644 --- a/IRaCIS.Core.Domain/Common/SystemBasicData.cs +++ b/IRaCIS.Core.Domain/Common/SystemBasicData.cs @@ -74,6 +74,7 @@ namespace IRaCIS.Core.Domain.Models public Guid? ParentId { get; set; } + [JsonIgnore] [ForeignKey("ParentId")] public SystemBasicData Parent { get; set; } diff --git a/IRaCIS.Core.Domain/Document/SystemDocument.cs b/IRaCIS.Core.Domain/Document/SystemDocument.cs index 35e6fceef..696d11860 100644 --- a/IRaCIS.Core.Domain/Document/SystemDocument.cs +++ b/IRaCIS.Core.Domain/Document/SystemDocument.cs @@ -15,15 +15,15 @@ namespace IRaCIS.Core.Domain.Models [Table("SystemDocument")] public class SystemDocument : Entity, IAuditUpdate, IAuditAdd,ISoftDelete { - + [JsonIgnore] public List SystemDocConfirmedUserList { get; set; } - + [JsonIgnore] public List NeedConfirmedUserTypeList { get; set; } - - [ForeignKey("FileTypeId")] + [JsonIgnore] + [ForeignKey("FileTypeId")] public Dictionary FileType { get; set; } diff --git a/IRaCIS.Core.Domain/Document/TrialDocUserTypeConfirmedUser.cs b/IRaCIS.Core.Domain/Document/TrialDocUserTypeConfirmedUser.cs index d0a91466f..0837fda3d 100644 --- a/IRaCIS.Core.Domain/Document/TrialDocUserTypeConfirmedUser.cs +++ b/IRaCIS.Core.Domain/Document/TrialDocUserTypeConfirmedUser.cs @@ -17,7 +17,7 @@ namespace IRaCIS.Core.Domain.Models //public Guid TrialId { get; set; } //public TrialUser TrialUser { get; set; } - + [JsonIgnore] public TrialDocument TrialDocument { get; set; } diff --git a/IRaCIS.Core.Domain/Document/TrialDocument.cs b/IRaCIS.Core.Domain/Document/TrialDocument.cs index b65b1b293..21f65047f 100644 --- a/IRaCIS.Core.Domain/Document/TrialDocument.cs +++ b/IRaCIS.Core.Domain/Document/TrialDocument.cs @@ -16,15 +16,15 @@ namespace IRaCIS.Core.Domain.Models public class TrialDocument : Entity, IAuditUpdate, IAuditAdd { - //需要确认的项目用户 通过TrialId 关联 用中间表过滤 - - - public List TrialDocConfirmedUserList { get; set; } + //需要确认的项目用户 通过TrialId 关联 用中间表过滤 + [JsonIgnore] + public List TrialDocConfirmedUserList { get; set; } + [JsonIgnore] public List NeedConfirmedUserTypeList { get; set; } - + [JsonIgnore] public Trial Trial { get; set; } - + [JsonIgnore] [ForeignKey("FileTypeId")] public Dictionary FileType { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index cc586d5dc..b05455b56 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -100,52 +100,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common #region 区分 - //系统文件 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocument))) - { - var entity = item.Entity as SystemDocument; - var userTypes = entity.NeedConfirmedUserTypeList; - if (userTypes == null) - { - userTypes = await _dbContext.SystemDocNeedConfirmedUserType.Where(x => x.SystemDocumentId == entity.Id).ToListAsync(); - } - - 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(entity, type, null, new - { - NeedConfirmedUserType = userTypeName, - }); - } - - - - - - - - // 项目文档 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocument))) - { - - var entity = item.Entity as TrialDocument; - var userTypes = entity.NeedConfirmedUserTypeList; - if (userTypes == null) - { - userTypes = await _dbContext.TrialDocNeedConfirmedUserType.Where(x => x.TrialDocumentId == entity.Id).ToListAsync(); - } - - 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(entity, type, null, new - { - NeedConfirmedUserType = usertypeName, - }); - - - } // 系统文件签署 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocConfirmedUser))) @@ -155,6 +109,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(entity, type, x => new InspectionConvertDTO() { GeneralId = x.Id, + + ObjectRelationParentId=x.SystemDocumentId + }, new { @@ -175,6 +132,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(entity as TrialDocUserTypeConfirmedUser, type, x => new InspectionConvertDTO() { TrialId = trialid, + ObjectRelationParentId = x.TrialDocumentId }, new { FileTypeId = trialDocument.FileTypeId, @@ -510,6 +468,65 @@ namespace IRaCIS.Core.Infra.EFCore.Common #region 已修改 + + //系统文件 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocument))) + { + var entity = item.Entity as SystemDocument; + + List needConfirmedUserTypeIdList = new List(); + + if (entity.NeedConfirmedUserTypeList == null) + { + needConfirmedUserTypeIdList = await _dbContext.SystemDocNeedConfirmedUserType.Where(x => x.SystemDocumentId == entity.Id).Select(t => t.NeedConfirmUserTypeId).ToListAsync(); + } + else + { + needConfirmedUserTypeIdList = entity.NeedConfirmedUserTypeList.Select(t => t.NeedConfirmUserTypeId).ToList(); + } + + + var userTypeNameList = await _dbContext.UserType.Where(x => needConfirmedUserTypeIdList.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync(); + var userTypeName = string.Join(",", userTypeNameList); + await InsertInspection(entity, type, null, new + { + NeedConfirmedUserType = userTypeName, + }); + } + + + + // 项目文档 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocument))) + { + + var entity = item.Entity as TrialDocument; + + List needConfirmedUserTypeIdList = new List(); + + if (entity.NeedConfirmedUserTypeList == null) + { + needConfirmedUserTypeIdList = await _dbContext.TrialDocNeedConfirmedUserType.Where(x => x.TrialDocumentId == entity.Id).Select(t => t.NeedConfirmUserTypeId).ToListAsync(); + } + else + { + needConfirmedUserTypeIdList = entity.NeedConfirmedUserTypeList.Select(t => t.NeedConfirmUserTypeId).ToList(); + } + + var usertypeNames = await _dbContext.UserType.Where(x => needConfirmedUserTypeIdList.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync(); + var usertypeName = string.Join(",", usertypeNames); + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { ObjectRelationParentId = x.TrialId }, + new + { + NeedConfirmedUserType = usertypeName, + }); + + + } + + + // 签名模板 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemBasicData))) { @@ -606,8 +623,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common } - - // 受试者 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject))) { @@ -638,7 +653,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage))) { var entity = item.Entity as VisitStage; - + await InsertInspection(item.Entity as VisitStage, type, x => new InspectionConvertDTO() { ObjectRelationParentId = x.TrialId @@ -696,7 +711,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(item.Entity as NoneDicomStudy, type, x => new InspectionConvertDTO() { - ObjectRelationParentId=x.SubjectVisitId, + ObjectRelationParentId = x.SubjectVisitId, }); @@ -709,31 +724,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common //}); } - //// 非Dicom文件 - //if (entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) - //{ - // var noneDicomStudyfile = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).Select(x => x.Entity).FirstOrDefault() as NoneDicomStudyFile; - // var noneDicomStudy = await _dbContext.NoneDicomStudy.Where(x => x.Id == noneDicomStudyfile.NoneDicomStudyId).FirstOrDefaultAsync(); - // if (noneDicomStudy != null) - // { - // var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == noneDicomStudyfile.NoneDicomStudyId).CountAsync(); - // var count = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).ToList().Count; - // if (type == "Deleted") - // { - // filecount = filecount - count; - // } - // else - // { - // filecount = filecount + count; - // } - // await InsertInspection(noneDicomStudy, type, null, new - // { - // FileCount = filecount, - // }); - - // } - //} #region 阅片人入组 @@ -967,7 +958,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common ObjectRelationParentId2 = entity.DoctorUserId - }); + }); } //申请重阅记录表 @@ -1109,7 +1100,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common Data = AddJsonItem(entityObj, otherItem), //准确来讲 此处称之为 RelationData 更贴合 为了兼容之前的数据 - CommonData = new {SiteCode= generalData.SiteCode,SubjectCode=generalData.SubjectCode}, + CommonData = new { SiteCode = generalData.SiteCode, SubjectCode = generalData.SubjectCode }, }.ToJsonStr(); @@ -1172,7 +1163,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common if (generalData.TrialId == null || generalData.SiteId == null || generalData.SubjectId == null) { - var info = await _dbContext.VisitTask.Where(x => x.Id == inspection.VisitTaskId).Select(x => new { SubjectCode=x.Subject.Code,TrialSiteCode=x.Subject.TrialSite.TrialSiteCode, SubjectId = x.SubjectId, x.Subject.SiteId, x.TrialId, x.SourceSubjectVisitId, ReadModuleSubjectVisitId = (Guid?)x.ReadModule.SubjectVisitId }).FirstOrDefaultAsync(); + var info = await _dbContext.VisitTask.Where(x => x.Id == inspection.VisitTaskId).Select(x => new { SubjectCode = x.Subject.Code, TrialSiteCode = x.Subject.TrialSite.TrialSiteCode, SubjectId = x.SubjectId, x.Subject.SiteId, x.TrialId, x.SourceSubjectVisitId, ReadModuleSubjectVisitId = (Guid?)x.ReadModule.SubjectVisitId }).FirstOrDefaultAsync(); generalData.TrialId = info?.TrialId ?? generalData.TrialId; @@ -1194,7 +1185,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common if (generalData.TrialId == null || generalData.SiteId == null || generalData.SubjectId == null) { var info = await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => - new { x.SubjectId, x.SiteId, x.TrialId ,SubjectCode = x.Subject.Code, TrialSiteCode = x.Subject.TrialSite.TrialSiteCode }).FirstOrDefaultAsync(); + new { x.SubjectId, x.SiteId, x.TrialId, SubjectCode = x.Subject.Code, TrialSiteCode = x.Subject.TrialSite.TrialSiteCode }).FirstOrDefaultAsync(); generalData.TrialId = info?.TrialId ?? generalData.TrialId; @@ -1498,6 +1489,33 @@ namespace IRaCIS.Core.Infra.EFCore.Common #region 待废弃 -by zhouhang 调整 + + //// 非Dicom文件 + //if (entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) + //{ + // var noneDicomStudyfile = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).Select(x => x.Entity).FirstOrDefault() as NoneDicomStudyFile; + // var noneDicomStudy = await _dbContext.NoneDicomStudy.Where(x => x.Id == noneDicomStudyfile.NoneDicomStudyId).FirstOrDefaultAsync(); + // if (noneDicomStudy != null) + // { + // var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == noneDicomStudyfile.NoneDicomStudyId).CountAsync(); + // var count = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).ToList().Count; + // if (type == "Deleted") + // { + // filecount = filecount - count; + // } + // else + // { + // filecount = filecount + count; + // } + + // await InsertInspection(noneDicomStudy, type, null, new + // { + // FileCount = filecount, + // }); + + // } + //} + /// /// 获取稽查通用数据 (每条稽查记录必须查询的) ///