|
|
|
|
@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore.ChangeTracking;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using ZiggyCreatures.Caching.Fusion;
|
|
|
|
|
using static IRaCIS.Core.Domain.Share.StaticData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
@ -39,16 +41,20 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IUserInfo _userInfo { get; set; }
|
|
|
|
|
|
|
|
|
|
public IFusionCache _fusionCache { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dbContext"></param>
|
|
|
|
|
/// <param name="userInfo"></param>
|
|
|
|
|
public AuditingData(IRaCISDBContext dbContext, IUserInfo userInfo)
|
|
|
|
|
public AuditingData(IRaCISDBContext dbContext, IUserInfo userInfo, IFusionCache fusionCache)
|
|
|
|
|
{
|
|
|
|
|
_dbContext = dbContext;
|
|
|
|
|
_userInfo = userInfo;
|
|
|
|
|
_userInfo.BatchId = _userInfo.BatchId == null ? NewId.NextGuid() : _userInfo.BatchId;
|
|
|
|
|
_fusionCache = fusionCache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -262,7 +268,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
var entity = item.Entity as ReadingImportFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var visitTaskInfo = await _dbContext.VisitTask.Where(x => x.Id == entity.VisitTaskId).Include(x=>x.DoctorUser).FirstOrDefaultAsync();
|
|
|
|
|
var visitTaskInfo = await _dbContext.VisitTask.Where(x => x.Id == entity.VisitTaskId).Include(x => x.DoctorUser).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
await InsertInspection<ReadingImportFile>(entity, type, x => new InspectionConvertDTO()
|
|
|
|
|
{
|
|
|
|
|
@ -3696,7 +3702,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
|
|
|
|
|
string questionName = string.Empty;
|
|
|
|
|
string questionAnswer = string.Empty;
|
|
|
|
|
if (thisQuestinonAnswer != null&& question!=null)
|
|
|
|
|
if (thisQuestinonAnswer != null && question != null)
|
|
|
|
|
{
|
|
|
|
|
questionName = _userInfo.IsEn_Us ? question.QuestionEnName : question.QuestionName;
|
|
|
|
|
questionAnswer = Translationunit(question.Type, question.Unit, question.CustomUnit, unitDataList, thisQuestinonAnswer.Answer);
|
|
|
|
|
@ -3857,7 +3863,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
|
|
|
|
|
entity.OrderMark = await _dbContext.ReadingQuestionTrial.Where(x => x.Id == entity.QuestionId).Select(x => x.OrderMark).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
entity.RowMark = entity.OrderMark+ entity.RowIndex.GetLesionMark();
|
|
|
|
|
entity.RowMark = entity.OrderMark + entity.RowIndex.GetLesionMark();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -4174,7 +4180,17 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
|
|
|
|
|
#region 处理标识
|
|
|
|
|
|
|
|
|
|
var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == inspection.Identification);
|
|
|
|
|
//批量记录instance 这种稽查的时候,减少数据库查询交互 --稽查缓存
|
|
|
|
|
var from = await _fusionCache.GetOrSetAsync(InspectionCacheKeys.FrontAuditConfig(inspection.Identification), async _ =>
|
|
|
|
|
{
|
|
|
|
|
return await _dbContext.FrontAuditConfig
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Identification == inspection.Identification);
|
|
|
|
|
},
|
|
|
|
|
TimeSpan.FromMinutes(10) // 缓存 10 分钟
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//var from = await _dbContext.FrontAuditConfig.FirstOrDefaultAsync(x => x.Identification == inspection.Identification);
|
|
|
|
|
|
|
|
|
|
inspection.ObjectTypeId = from?.ObjectTypeId;
|
|
|
|
|
inspection.OptTypeId = from?.OptTypeId;
|
|
|
|
|
//inspection.ChildrenTypeId = from?.ChildrenTypeId;
|
|
|
|
|
@ -4273,14 +4289,20 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (inspection.VisitTaskId != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (generalData.TrialId == null || generalData.TrialSiteId == null || generalData.SubjectId == null || generalData.TrialReadingCriterionId == 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.TrialSiteId, x.TrialId, x.SourceSubjectVisitId, ReadModuleSubjectVisitId = (Guid?)x.ReadModule.SubjectVisitId, x.TrialReadingCriterionId }).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.TrialSiteId, x.TrialId, x.SourceSubjectVisitId, ReadModuleSubjectVisitId = (Guid?)x.ReadModule.SubjectVisitId, x.TrialReadingCriterionId }).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
var info = await _fusionCache.GetOrSetAsync(InspectionCacheKeys.VisitTask(inspection.VisitTaskId), async _ =>
|
|
|
|
|
{
|
|
|
|
|
return 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.TrialSiteId, x.TrialId, x.SourceSubjectVisitId, ReadModuleSubjectVisitId = (Guid?)x.ReadModule.SubjectVisitId, x.TrialReadingCriterionId }).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
TimeSpan.FromDays(1) // 缓存 1天
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
generalData.TrialReadingCriterionId = info?.TrialReadingCriterionId ?? generalData.TrialReadingCriterionId;
|
|
|
|
|
generalData.TrialId = info?.TrialId ?? generalData.TrialId;
|
|
|
|
|
@ -4299,7 +4321,14 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
{
|
|
|
|
|
if (generalData.TrialId == null)
|
|
|
|
|
{
|
|
|
|
|
var info = await _dbContext.ReadingQuestionCriterionTrial.Where(x => x.Id == inspection.TrialReadingCriterionId).Select(x => new { x.TrialId }).FirstOrDefaultAsync();
|
|
|
|
|
var info = await _fusionCache.GetOrSetAsync(InspectionCacheKeys.ReadingQuestionCriterionTrial(inspection.TrialReadingCriterionId), async _ =>
|
|
|
|
|
{
|
|
|
|
|
return await _dbContext.ReadingQuestionCriterionTrial.Where(x => x.Id == inspection.TrialReadingCriterionId).Select(x => new { x.TrialId }).FirstOrDefaultAsync();
|
|
|
|
|
},
|
|
|
|
|
TimeSpan.FromDays(1) // 缓存 1天
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//var info = await _dbContext.ReadingQuestionCriterionTrial.Where(x => x.Id == inspection.TrialReadingCriterionId).Select(x => new { x.TrialId }).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
generalData.TrialId = info?.TrialId ?? generalData.TrialId;
|
|
|
|
|
}
|
|
|
|
|
@ -4311,8 +4340,17 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
{
|
|
|
|
|
if (generalData.TrialId == null || generalData.TrialSiteId == null || generalData.SubjectId == null)
|
|
|
|
|
{
|
|
|
|
|
var info = await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x =>
|
|
|
|
|
new { x.SubjectId, x.TrialSiteId, x.TrialId, SubjectCode = x.Subject.Code, TrialSiteCode = x.Subject.TrialSite.TrialSiteCode }).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
var info = await _fusionCache.GetOrSetAsync(InspectionCacheKeys.SubjectVisit(inspection.SubjectVisitId), async _ =>
|
|
|
|
|
{
|
|
|
|
|
return await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x =>
|
|
|
|
|
new { x.SubjectId, x.TrialSiteId, x.TrialId, SubjectCode = x.Subject.Code, TrialSiteCode = x.Subject.TrialSite.TrialSiteCode }).FirstOrDefaultAsync();
|
|
|
|
|
},
|
|
|
|
|
TimeSpan.FromDays(1) // 缓存 1天
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// var info = await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x =>
|
|
|
|
|
//new { x.SubjectId, x.TrialSiteId, x.TrialId, SubjectCode = x.Subject.Code, TrialSiteCode = x.Subject.TrialSite.TrialSiteCode }).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generalData.TrialId = info?.TrialId ?? generalData.TrialId;
|
|
|
|
|
@ -4332,7 +4370,15 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
{
|
|
|
|
|
if (generalData.TrialId == null || generalData.TrialSiteId == null)
|
|
|
|
|
{
|
|
|
|
|
var info = await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => new { SubjectId = x.Id, x.TrialSiteId, x.TrialId, SubjectCode = x.Code, TrialSiteCode = x.TrialSite.TrialSiteCode }).FirstOrDefaultAsync();
|
|
|
|
|
//var info = await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => new { SubjectId = x.Id, x.TrialSiteId, x.TrialId, SubjectCode = x.Code, TrialSiteCode = x.TrialSite.TrialSiteCode }).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
var info = await _fusionCache.GetOrSetAsync(InspectionCacheKeys.SubjecSiteInfo(inspection.SubjectId), async _ =>
|
|
|
|
|
{
|
|
|
|
|
return await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => new { SubjectId = x.Id, x.TrialSiteId, x.TrialId, SubjectCode = x.Code, TrialSiteCode = x.TrialSite.TrialSiteCode }).FirstOrDefaultAsync();
|
|
|
|
|
},
|
|
|
|
|
TimeSpan.FromDays(1) // 缓存 1天
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
@ -4348,11 +4394,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|
|
|
|
generalData.TrialSiteId = info?.TrialSiteId ?? generalData.TrialSiteId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//以后移除
|
|
|
|
|
generalData.SiteCode = info?.TrialSiteCode ?? generalData.SiteCode;
|
|
|
|
|
generalData.SubjectCode = info?.SubjectCode ?? generalData.SubjectCode;
|
|
|
|
|
|