修改一版

Uat_Study
he 2022-06-06 17:32:40 +08:00
parent 198a8601be
commit 46b5846d0c
5 changed files with 67 additions and 97 deletions

View File

@ -86,9 +86,9 @@ namespace IRaCIS.Core.API.Controllers
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost, Route("Inspection/GetInspectionData")] [HttpPost, Route("Inspection/GetInspectionData")]
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto) public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionList(GetDataInspectionDto dto)
{ {
return await _inspectionService.GetInspectionData(dto); return await _inspectionService.GetInspectionList(dto);
} }
#endregion #endregion

View File

@ -84,7 +84,7 @@
Financials /Monthly Payment 列表查询接口 Financials /Monthly Payment 列表查询接口
</summary> </summary>
</member> </member>
<member name="M:IRaCIS.Core.API.Controllers.InspectionController.GetInspectionData(IRaCIS.Core.Application.Service.Inspection.DTO.GetDataInspectionDto)"> <member name="M:IRaCIS.Core.API.Controllers.InspectionController.GetInspectionList(IRaCIS.Core.Application.Service.Inspection.DTO.GetDataInspectionDto)">
<summary> <summary>
获取稽查数据 获取稽查数据
</summary> </summary>

View File

@ -25,17 +25,17 @@ namespace IRaCIS.Core.Application.Service.Inspection
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto) public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionList(GetDataInspectionDto dto)
{ {
//_repository.GetQueryable.GetQueryable < DataInspection > //_repository.GetQueryable.GetQueryable < DataInspection >
var trialfirst= await _repository.GetQueryable< Trial >().Where(x=>x.Id== dto.TrialId).AsNoTracking().FirstOrDefaultAsync(); var trialData= await _repository.GetQueryable<Trial>().Where(x=>x.Id== dto.TrialId).AsNoTracking().FirstOrDefaultAsync();
trialfirst.TrialFinishTime = trialfirst.TrialFinishTime == null ? DateTime.Now : trialfirst.TrialFinishTime; trialData.TrialFinishTime = trialData.TrialFinishTime == null ? DateTime.Now : trialData.TrialFinishTime;
#region 逻辑代码 #region 逻辑代码
var query = from data in _repository.GetQueryable<DataInspection>().Where(x => (x.TrialId == dto.TrialId)||(x.TrialId==null&&x.CreateTime> trialfirst.CreateTime&&x.CreateTime < trialfirst.TrialFinishTime)) var query = from data in _repository.GetQueryable<DataInspection>().Where(x => (x.TrialId == dto.TrialId)||(x.TrialId==null&&x.CreateTime> trialData.CreateTime&&x.CreateTime < trialData.TrialFinishTime))
join trial in _repository.GetQueryable<Trial>().IgnoreQueryFilters() on data.TrialId equals trial.Id into trialtemp join trial in _repository.GetQueryable<Trial>().IgnoreQueryFilters() on data.TrialId equals trial.Id into trialtemp
from leftrial in trialtemp.DefaultIfEmpty() from leftrial in trialtemp.DefaultIfEmpty()
@ -127,7 +127,6 @@ namespace IRaCIS.Core.Application.Service.Inspection
IsFrontAdd=data.IsFrontAdd, IsFrontAdd=data.IsFrontAdd,
BatchId=data.BatchId, BatchId=data.BatchId,
OptTypeName = leftOptType.Value, OptTypeName = leftOptType.Value,
}; };
query = query.WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId) query = query.WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId)
@ -141,14 +140,12 @@ namespace IRaCIS.Core.Application.Service.Inspection
.WhereIf(!dto.OpByUserName.IsNullOrEmpty(), x => x.CreateUserName.Contains(dto.OpByUserName)) .WhereIf(!dto.OpByUserName.IsNullOrEmpty(), x => x.CreateUserName.Contains(dto.OpByUserName))
//.WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo)) //.WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo))
.WhereIf(dto.IsSign != null, x => x.IsSign == dto.IsSign); .WhereIf(dto.IsSign != null, x => x.IsSign == dto.IsSign);
#endregion #endregion
dto.Asc = false; dto.Asc = false;
return await query.ToPagedListAsync(dto.PageIndex, dto.PageSize, "CreateTime", dto.Asc); return await query.ToPagedListAsync(dto.PageIndex, dto.PageSize,"CreateTime", dto.Asc);
} }

View File

@ -11,7 +11,7 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface
public interface IInspectionService public interface IInspectionService
{ {
Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto); Task<PageOutput<GetDataInspectionOutDto>> GetInspectionList(GetDataInspectionDto dto);

View File

@ -85,45 +85,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
} }
/// <summary>
/// 需要赋值的GeneralId
/// </summary>
private List<Type> NeedSetGeneralIdList
{
get
{
return new List<Type>()
{
typeof(SystemDocument),
typeof(SystemBasicData),
typeof(Trial),
typeof(VisitStage),
typeof(TrialDocument),
typeof(SystemDocConfirmedUser),
typeof(TrialDocUserTypeConfirmedUser),
typeof(Enroll),
typeof(EnrollDetail),
typeof(TrialSite),
typeof(TrialUser),
typeof(TrialSiteUser),
typeof(TrialSiteSurvey),
typeof(TrialQCQuestion),
typeof(DicomStudy),
typeof(DicomSeries),
typeof(NoneDicomStudy),
typeof(CheckChallengeDialog),
typeof(PreviousSurgery),
typeof(PreviousHistory),
typeof(PreviousOther),
typeof(QCChallenge),
typeof(QCChallengeDialog),
typeof(QCQuestion),
typeof(ConsistencyCheckFile),
typeof(DataInspection),
};
}
}
/// <summary> /// <summary>
/// 插入Add的实体 /// 插入Add的实体
@ -170,7 +132,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
var entity = item.Entity as Trial; var entity = item.Entity as Trial;
List<string> trials = new List<string>(); List<string> trialDics = new List<string>();
var dictionaryIds = new List<Guid>(); var dictionaryIds = new List<Guid>();
if (entity.TrialDicList == null || entity.TrialDicList.Count == 0) if (entity.TrialDicList == null || entity.TrialDicList.Count == 0)
{ {
@ -183,7 +145,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
trials = await this._dbContext.Dictionary.Where(x => dictionaryIds.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync(); trialDics = await this._dbContext.Dictionary.Where(x => dictionaryIds.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync();
await InsertInspection<Trial>(item.Entity as Trial, type, x => new DataInspection() await InsertInspection<Trial>(item.Entity as Trial, type, x => new DataInspection()
@ -194,7 +156,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
GeneralId = x.Id, GeneralId = x.Id,
}, new }, new
{ {
TrialDicList = string.Join(",", trials) TrialDicList = string.Join(",", trialDics)
}, item.OriginalValues); }, item.OriginalValues);
} }
@ -204,10 +166,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as VisitStage; var entity = item.Entity as VisitStage;
var VisitPlanStatus = await this._dbContext.Trial.Where(x => x.Id == entity.TrialId).Select(x => x.VisitPlanConfirmed).FirstOrDefaultAsync(); var visitPlanStatus = await this._dbContext.Trial.Where(x => x.Id == entity.TrialId).Select(x => x.VisitPlanConfirmed).FirstOrDefaultAsync();
if (type == "Add") if (type == "Add")
{ {
VisitPlanStatus = false; visitPlanStatus = false;
} }
await InsertInspection<VisitStage>(item.Entity as VisitStage, type, x => new DataInspection() await InsertInspection<VisitStage>(item.Entity as VisitStage, type, x => new DataInspection()
{ {
@ -215,7 +177,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
GeneralId = x.Id, GeneralId = x.Id,
}, new }, new
{ {
VisitPlanStatus = VisitPlanStatus, VisitPlanStatus = visitPlanStatus,
}); });
} }
@ -319,7 +281,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SiteAliasName = entity.TrialSiteAliasName, SiteAliasName = entity.TrialSiteAliasName,
City = entity.Site.City, City = entity.Site.City,
Country = entity.Site.Country, Country = entity.Site.Country,
Status = entity.IsDeleted ? "禁用" : "启用",
}); });
} }
@ -340,7 +301,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
EMail = user.EMail, EMail = user.EMail,
Phone = user.Phone, Phone = user.Phone,
OrganizationName = user.OrganizationName, OrganizationName = user.OrganizationName,
State = entity.IsDeleted ? "退出" : "加入",
}); });
} }
@ -386,7 +347,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SiteAliasName = entity.TrialSite.TrialSiteAliasName, SiteAliasName = entity.TrialSite.TrialSiteAliasName,
City = entity.Site.City, City = entity.Site.City,
Country = entity.Site.Country, Country = entity.Site.Country,
Status = entity.IsDeleted ? "禁用" : "启用",
UserName = user.UserName, UserName = user.UserName,
UserRealName = user.FullName, UserRealName = user.FullName,
UserType = userType.UserTypeShortName, UserType = userType.UserTypeShortName,
@ -429,7 +390,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
Email = entity.Email, Email = entity.Email,
PreliminaryUser = entity.PreliminaryUser == null ? "" : entity.PreliminaryUser.LastName + " / " + entity.PreliminaryUser.FirstName, PreliminaryUser = entity.PreliminaryUser == null ? "" : entity.PreliminaryUser.LastName + " / " + entity.PreliminaryUser.FirstName,
ReviewerUser = entity.ReviewerUser == null ? "" : entity.ReviewerUser.LastName + " / " + entity.ReviewerUser.FirstName, ReviewerUser = entity.ReviewerUser == null ? "" : entity.ReviewerUser.LastName + " / " + entity.ReviewerUser.FirstName,
IsDeleted = entity.IsDeleted ? "是" : "否",
}); });
} }
@ -459,7 +420,7 @@ 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 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();
await InsertInspection<Subject>(entity, type, x => new DataInspection() await InsertInspection<Subject>(entity, type, x => new DataInspection()
{ {
@ -467,7 +428,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SubjectCode = x.Code, SubjectCode = x.Code,
}, new }, new
{ {
FinalSubjectVisitName = FinalSubjectVisitName, FinalSubjectVisitName = finalSubjectVisitName,
}); });
} }
@ -504,7 +465,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
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 entity = item.Entity as NoneDicomStudy; var entity = item.Entity as NoneDicomStudy;
var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync(); var fileCount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync();
await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new DataInspection() await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new DataInspection()
@ -512,7 +473,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
GeneralId = x.Id, GeneralId = x.Id,
}, new }, new
{ {
FileCount = filecount, FileCount = fileCount,
}); });
} }
@ -546,7 +507,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
//一致性核查 //一致性核查 // 特殊GeneralId
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog)))
{ {
@ -692,7 +653,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}); });
} }
// 质疑信息 // 质疑信息 // 特殊GeneralId
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 reason = string.Empty; var reason = string.Empty;
@ -752,24 +713,24 @@ 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 entitylist = entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)).Select(x => x.Entity as TrialQCQuestionAnswer).ToList();
var firstentity = entitylist.FirstOrDefault(); var firstEntity = entitylist.FirstOrDefault();
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstentity.SubjectVisitId).FirstOrDefaultAsync(); var subjectVisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstEntity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit(); subjectVisit = subjectVisit ?? new SubjectVisit();
if (type == "Add") if (type == "Add")
{ {
await AddInspectionRecordAsync(new DataInspection() await AddInspectionRecordAsync(new DataInspection()
{ {
SiteId = subjectvisit.SiteId, SiteId = subjectVisit.SiteId,
Identification = $"{_userInfo.RequestUrl}/{ firstentity.GetType().Name}/{type}", Identification = $"{_userInfo.RequestUrl}/{ firstEntity.GetType().Name}/{type}",
SubjectId = subjectvisit.SubjectId, SubjectId = subjectVisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectVisit.VisitName,
TrialId = subjectvisit.TrialId, TrialId = subjectVisit.TrialId,
SubjectVisitId = subjectvisit.Id, SubjectVisitId = subjectVisit.Id,
GeneralId = subjectvisit.Id, GeneralId = subjectVisit.Id,
}, new }, new
{ {
QcQuestionAnswerCommands = await Getdata(entitylist), QcQuestionAnswerCommands = await Getdata(entitylist),
@ -778,19 +739,19 @@ namespace IRaCIS.Core.Infra.EFCore.Common
else if (type == "Update") else if (type == "Update")
{ {
var questionids = entitylist.Where(x => x.SubjectVisitId == subjectvisit.Id).Select(x => x.Id).ToList(); var questionIds = entitylist.Where(x => x.SubjectVisitId == subjectVisit.Id).Select(x => x.Id).ToList();
var createUserId = entitylist.Select(x => x.CreateUserId).FirstOrDefault(); 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(); var noUpdateData = _dbContext.TrialQCQuestionAnswer.Where(x => x.CreateUserId== createUserId&& x.SubjectVisitId == subjectVisit.Id && !questionIds.Contains(x.Id)).ToList();
entitylist.AddRange(noupdatedata); entitylist.AddRange(noUpdateData);
await AddInspectionRecordAsync(new DataInspection() await AddInspectionRecordAsync(new DataInspection()
{ {
Identification = $"{_userInfo.RequestUrl}/{ firstentity.GetType().Name}/{type}", Identification = $"{_userInfo.RequestUrl}/{ firstEntity.GetType().Name}/{type}",
SiteId = subjectvisit.SiteId, SiteId = subjectVisit.SiteId,
SubjectId = subjectvisit.SubjectId, SubjectId = subjectVisit.SubjectId,
TrialId = subjectvisit.TrialId, TrialId = subjectVisit.TrialId,
SubjectVisitId = subjectvisit.Id, SubjectVisitId = subjectVisit.Id,
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectVisit.VisitName,
GeneralId = subjectvisit.Id, GeneralId = subjectVisit.Id,
}, new }, new
{ {
QcQuestionAnswerCommands = await Getdata(entitylist), QcQuestionAnswerCommands = await Getdata(entitylist),
@ -924,8 +885,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break; break;
} }
inspection.Identification = $"{_userInfo.RequestUrl}/{ entityTypeName}/{type}"; inspection.Identification = $"{_userInfo.RequestUrl}/{ entityTypeName}/{type}";
#region 注释 #region 注释
@ -980,11 +939,25 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// <param name="data">数据</param> /// <param name="data">数据</param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception> /// <exception cref="BusinessValidationFailedException"></exception>
public async Task AddInspectionRecordAsync(DataInspection add, dynamic data, object otherItem = null) public async Task AddInspectionRecordAsync(DataInspection add, object data, object otherItem = null)
{ {
MapData(data, add); MapData(data, add);
InspectionGeneralData generalData = new InspectionGeneralData(); InspectionGeneralData generalData = new InspectionGeneralData()
MapData(add, generalData); {
CreateUserName = add.CreateUserName,
SiteCode = add.SiteCode,
SiteId = add.SiteId,
SiteName = add.SiteName,
SubjectCode = add.SubjectCode,
SubjectId = add.SubjectId,
SubjectVisitId = add.SubjectVisitId,
SubjectVisitName = add.SubjectVisitName,
ResearchProgramNo = add.ResearchProgramNo,
RoleName = add.RoleName,
TrialId = add.TrialId,
TrialName = add.TrialName
};
await SetInspectionNameValue(generalData); await SetInspectionNameValue(generalData);
#region 处理标识 #region 处理标识
@ -1027,14 +1000,14 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// <summary> /// <summary>
/// 往json里面添加属性 /// 往json里面添加属性
/// </summary> /// </summary>
/// <param name="json">json</param> /// <param name="jsonObj">json</param>
/// <param name="otherItem">添加对象</param> /// <param name="otherItem">添加对象</param>
/// <returns></returns> /// <returns></returns>
public IDictionary<string, object> AddJsonItem(dynamic json, object otherItem = null) public IDictionary<string, object> AddJsonItem(object jsonObj, object otherItem = null)
{ {
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>((json as object).ToJsonStr()); var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>((jsonObj).ToJsonStr());
if (otherItem == null) if (otherItem == null)
{ {