修改稽查
parent
5a046da4d0
commit
7c08e7606c
|
@ -195,7 +195,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var currentInspection = await _dataInspectionRepository.Where(t => t.Id == id).Select(t => new { t.GeneralId, t.ObjectRelationParentId, t.CreateTime }).FirstOrDefaultAsync();
|
||||
|
||||
var beforeId = await _dataInspectionRepository.Where(x => x.GeneralId == currentInspection.GeneralId && x.ObjectRelationParentId == currentInspection.ObjectRelationParentId && x.CreateTime <= currentInspection.CreateTime && x.Id != id).OrderByDescending(x => x.CreateTime).Select(t => t.Id)
|
||||
var beforeId = await _dataInspectionRepository.Where(x => x.GeneralId == currentInspection.GeneralId /*&& x.ObjectRelationParentId == currentInspection.ObjectRelationParentId*/ && x.CreateTime <= currentInspection.CreateTime && x.Id != id).OrderByDescending(x => x.CreateTime).Select(t => t.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
List<Guid> searchGuidList = new List<Guid>() { id };
|
||||
|
@ -245,7 +245,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var objectLsit = new List<object>();
|
||||
|
||||
var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.ObjectRelationParentId2, item.CreateTime, item.BatchId, objectLsit);
|
||||
var commonDataObjList = await GetRelationParentData( item.Id,item.ObjectRelationParentId, item.ObjectRelationParentId2, item.CreateTime, item.BatchId, objectLsit);
|
||||
|
||||
var currentDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(jsonDict[nameof(InspectionJsonDetail.CommonData)].ToJsonStr());
|
||||
|
||||
|
@ -347,12 +347,12 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
private async Task AddJsonObjectToDic(Guid? objectRelationParentId, DateTime createTime, Guid batchId, List<object> objectLsit)
|
||||
private async Task AddJsonObjectToDic(Guid id, Guid? objectRelationParentId, DateTime createTime, Guid batchId, List<object> objectLsit)
|
||||
{
|
||||
if (objectRelationParentId != null)
|
||||
{
|
||||
//父子层级的数据可能在同一个批次 进行更新 但是后插入的是父层级的数据 找父层级的稽查应该优先同一批次的
|
||||
var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId && (t.CreateTime <= createTime || t.BatchId == batchId)).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail, t.BatchId, t.ObjectRelationParentId2, t.EntityName }).FirstOrDefaultAsync();
|
||||
var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId && (t.CreateTime <= createTime || t.BatchId == batchId) && t.Id !=id).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail, t.BatchId, t.ObjectRelationParentId2, t.EntityName ,t.Id}).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
if (relationParentInspection != null)
|
||||
|
@ -386,8 +386,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
await AddJsonObjectToDic(relationParentInspection.ObjectRelationParentId, relationParentInspection.CreateTime, relationParentInspection.BatchId, objectLsit);
|
||||
await AddJsonObjectToDic( relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId, objectLsit);
|
||||
await AddJsonObjectToDic(relationParentInspection.Id, relationParentInspection.ObjectRelationParentId, relationParentInspection.CreateTime, relationParentInspection.BatchId, objectLsit);
|
||||
await AddJsonObjectToDic(relationParentInspection.Id, relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId, objectLsit);
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -405,10 +405,10 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
private async Task<List<object>> GetRelationParentData(Guid? objectRelationParentId, Guid? objectRelationParentId2, DateTime createTime, Guid batchId, List<object> objectLsit)
|
||||
private async Task<List<object>> GetRelationParentData(Guid id,Guid? objectRelationParentId, Guid? objectRelationParentId2, DateTime createTime, Guid batchId, List<object> objectLsit)
|
||||
{
|
||||
await AddJsonObjectToDic(objectRelationParentId, createTime, batchId, objectLsit);
|
||||
await AddJsonObjectToDic(objectRelationParentId2, createTime, batchId, objectLsit);
|
||||
await AddJsonObjectToDic(id,objectRelationParentId, createTime, batchId, objectLsit);
|
||||
await AddJsonObjectToDic(id,objectRelationParentId2, createTime, batchId, objectLsit);
|
||||
|
||||
#region 废弃
|
||||
//if (objectRelationParentId != null)
|
||||
|
|
|
@ -121,8 +121,17 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
}
|
||||
|
||||
if (inDto.ReadingCategorys.Count > 0)
|
||||
{
|
||||
await _enrollReadingCategoryRepository.BatchDeleteNoTrackingAsync(x => x.EnrollId == inDto.EnrollId);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId);
|
||||
}
|
||||
|
||||
|
||||
List<EnrollReadingCategory> enrollReadings = inDto.ReadingCategorys.Select(x => new EnrollReadingCategory()
|
||||
{
|
||||
EnrollId = inDto.EnrollId,
|
||||
|
|
|
@ -9,10 +9,10 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public partial class Enroll : Entity,IAuditUpdate,IAuditAdd
|
||||
{
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey("TrialId")]
|
||||
public virtual Trial Trial { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Doctor Doctor { get; set; }
|
||||
|
||||
//public TrialPaymentPrice TrialPaymentPrice { get; set; }
|
||||
|
@ -71,7 +71,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public List<EnrollReadingCategory> EnrollReadingCategoryList { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey("EnrollId")]
|
||||
public Enroll Enroll { get; set; }
|
||||
}
|
||||
|
|
|
@ -715,14 +715,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 阅片人入组
|
||||
|
||||
//阅片人入组
|
||||
|
||||
//阅片人入组 父层级未记录稽查(医生)
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll)))
|
||||
{
|
||||
|
||||
|
@ -738,39 +734,109 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
Name = doctor.FullName,
|
||||
ChineseName = doctor.ChineseName,
|
||||
Email = doctor.EMail,
|
||||
|
||||
|
||||
IsUploadedACKSOW = entity.AttachmentId != Guid.Empty,
|
||||
|
||||
//子层级的数据 记录到父层级 必须查询 不然找上一条时数据不准
|
||||
ReadingCategoryList = readingCategoryList
|
||||
});
|
||||
}
|
||||
|
||||
//独立阅片人 状态修改 上传SoW 子对象稽查记录到父对象 要求 记录的数据一致
|
||||
//独立阅片人 设置阅片类型 这里对于操作人 不区分 添加 编辑 删除 只有设置(相当于更新)
|
||||
|
||||
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 enrollId = list.Select(t => t.EnrollId).FirstOrDefault();
|
||||
var enroll = await _dbContext.Enroll.Include(t => t.Doctor).FirstAsync(t => t.Id == enrollId);
|
||||
|
||||
await InsertInspection<Enroll>(enroll, type, x => new InspectionConvertDTO()
|
||||
var first = list.FirstOrDefault();
|
||||
|
||||
var enrollId = first.EnrollId;
|
||||
|
||||
Guid? trialId = Guid.Empty;
|
||||
|
||||
if (first.Enroll != null)
|
||||
{
|
||||
GeneralId = enroll.Id,
|
||||
ObjectRelationParentId = x.TrialId
|
||||
trialId = first.Enroll.TrialId;
|
||||
}
|
||||
else
|
||||
{
|
||||
trialId = await _dbContext.Enroll.Where(x => x.Id == enrollId).Select(t => t.TrialId).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
||||
await InsertInspection<EnrollReadingCategory>(first, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
//GeneralId 和ObjectRelationParentId 一样 会成环 所以查询的时候 需要排除自身
|
||||
GeneralId = enrollId,
|
||||
|
||||
TrialId = trialId,
|
||||
|
||||
ObjectRelationParentId = enrollId
|
||||
}, new
|
||||
{
|
||||
//父层级的数据 暂时没有记录稽查 所以这里必须查
|
||||
Name = enroll.Doctor.FullName,
|
||||
ChineseName = enroll.Doctor.ChineseName,
|
||||
Email = enroll.Doctor.EMail,
|
||||
|
||||
IsUploadedACKSOW = enroll.AttachmentId != Guid.Empty,
|
||||
ReadingCategoryList = list.Select(t => t.ReadingCategory).ToList()
|
||||
//子层级只需要记录自己这边的信息就好了
|
||||
ReadingCategoryList = type == AuditOpt.Deleted ? null : list.Select(t => t.ReadingCategory).ToList(),
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 阅片期临床数据
|
||||
|
||||
//阅片期临床数据 父层级未记录稽查(项目临床数据设置)
|
||||
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingClinicalData)))
|
||||
{
|
||||
var entity = item.Entity as ReadingClinicalData;
|
||||
|
||||
if (entity.ClinicalDataTrialSet == null && entity.ClinicalDataTrialSetId != Guid.Empty)
|
||||
{
|
||||
entity.ClinicalDataTrialSet = await _dbContext.ClinicalDataTrialSet.FindAsync(entity.ClinicalDataTrialSetId);
|
||||
}
|
||||
|
||||
var fileCount = await _dbContext.ReadingClinicalDataPDF.Where(x => x.ReadingClinicalDataId == entity.Id).CountAsync();
|
||||
|
||||
await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
SubjectVisitId = x.IsVisit ? x.ReadingId : null,
|
||||
|
||||
ObjectRelationParentId = entity.ClinicalDataTrialSetId,
|
||||
}, new
|
||||
{
|
||||
entity.ClinicalDataTrialSet.ClinicalUploadType,
|
||||
entity.ClinicalDataTrialSet.ClinicalDataSetName,
|
||||
entity.ClinicalDataTrialSet.ClinicalDataLevel,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingClinicalDataPDF)))
|
||||
{
|
||||
var entity = item.Entity as ReadingClinicalDataPDF;
|
||||
|
||||
var fileCount = await _dbContext.ReadingClinicalDataPDF.Where(x => x.ReadingClinicalDataId == entity.Id).CountAsync();
|
||||
|
||||
await InsertInspection<ReadingClinicalDataPDF>(item.Entity as ReadingClinicalDataPDF, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
SubjectId = x.SubjectId,
|
||||
IsDistinctionInterface = false,
|
||||
|
||||
ObjectRelationParentId = entity.ReadingClinicalDataId
|
||||
}, new
|
||||
{
|
||||
IsCRCUpload = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region Subject 阅片期和 临床数据
|
||||
|
||||
//阅片期计划
|
||||
|
@ -839,45 +905,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
});
|
||||
}
|
||||
|
||||
//阅片期临床数据
|
||||
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingClinicalData)))
|
||||
{
|
||||
var entity = item.Entity as ReadingClinicalData;
|
||||
|
||||
if (entity.ClinicalDataTrialSet == null && entity.ClinicalDataTrialSetId != Guid.Empty)
|
||||
{
|
||||
entity.ClinicalDataTrialSet = await _dbContext.ClinicalDataTrialSet.FindAsync(entity.ClinicalDataTrialSetId);
|
||||
}
|
||||
|
||||
await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
SubjectVisitId = x.IsVisit ? x.ReadingId : null,
|
||||
|
||||
ObjectRelationParentId = entity.ClinicalDataTrialSetId,
|
||||
}, new
|
||||
{
|
||||
entity.ClinicalDataTrialSet.ClinicalUploadType,
|
||||
entity.ClinicalDataTrialSet.ClinicalDataSetName,
|
||||
entity.ClinicalDataTrialSet.ClinicalDataLevel,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingClinicalDataPDF)))
|
||||
{
|
||||
var entity = item.Entity as ReadingClinicalDataPDF;
|
||||
|
||||
await InsertInspection<ReadingClinicalDataPDF>(item.Entity as ReadingClinicalDataPDF, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
SubjectId = x.SubjectId,
|
||||
IsDistinctionInterface = false,
|
||||
|
||||
ObjectRelationParentId = entity.ReadingClinicalDataId
|
||||
}, new
|
||||
{
|
||||
IsCRCUpload = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
@ -894,9 +922,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
IsDistinctionInterface = false
|
||||
}, new
|
||||
{
|
||||
UserFullName = entity.FullName,
|
||||
entity.UserCode,
|
||||
entity.UserName
|
||||
UserRealName = entity.FullName,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -983,8 +1009,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
ObjectRelationParentId = entity.VisitTaskId,
|
||||
|
||||
ObjectRelationParentId2 = entity.MedicalManagerUserId
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -996,9 +1020,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
|
||||
await InsertInspection<TaskConsistentRule>(entity, type, x => new InspectionConvertDTO()
|
||||
{
|
||||
|
||||
ObjectRelationParentId = entity.TrialId
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1165,10 +1187,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
var info = (await _dbContext.VisitTask.Where(x => x.Id == inspection.VisitTaskId).Select(x => new { SubjectId = x.SubjectId, x.Subject.SiteId, x.TrialId, x.SourceSubjectVisitId, ReadModuleSubjectVisitId = (Guid?)x.ReadModule.SubjectVisitId }).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
|
||||
generalData.TrialId = info.TrialId;
|
||||
generalData.SubjectId = info.SubjectId;
|
||||
generalData.SiteId = info.SiteId;
|
||||
generalData.SubjectVisitId = info.SourceSubjectVisitId!=null ?info.SourceSubjectVisitId: (info.ReadModuleSubjectVisitId != null ? info.ReadModuleSubjectVisitId : null ) ;
|
||||
generalData.TrialId = info?.TrialId ?? generalData.TrialId;
|
||||
generalData.SubjectId = info?.SubjectId ?? generalData.SubjectId;
|
||||
generalData.SiteId = info?.SiteId ?? generalData.SiteId;
|
||||
generalData.SubjectVisitId = info?.SourceSubjectVisitId != null ? info?.SourceSubjectVisitId : (info?.ReadModuleSubjectVisitId != null ? info?.ReadModuleSubjectVisitId : null);
|
||||
}
|
||||
|
||||
// Suject visit 都进行了设置 不用处理
|
||||
|
|
Loading…
Reference in New Issue