修改site关联

This commit is contained in:
2024-06-03 14:37:38 +08:00
parent 4db3860ade
commit 0e23719c7b
101 changed files with 354 additions and 3290 deletions
@@ -135,8 +135,6 @@ namespace IRaCIS.Core.Application.ViewModel
//[NotDefault]
//public Guid TrialId { get; set; }
//[NotDefault]
//public Guid SiteId { get; set; }
}
@@ -7,7 +7,7 @@ namespace IRaCIS.Application.Contracts
{
public Guid Id { get; set; }
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public string MainCenter { get; set; } = string.Empty;
public DateTime OptTime { get; set; }
public int State { get; set; }
@@ -38,7 +38,7 @@ namespace IRaCIS.Core.Application.Contracts.DTO
public class TrialSiteCommand
{
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public string SiteName { get; set; }
@@ -54,6 +54,9 @@ namespace IRaCIS.Core.Application.Contracts.DTO
public Guid Id { get; set; }
public string TrialSiteName { get; set; } = String.Empty;
public string TrialSiteAliasName { get; set; } = String.Empty;
public string TrialSiteCode { get; set; } = String.Empty;
@@ -65,7 +68,7 @@ namespace IRaCIS.Core.Application.Contracts.DTO
public class AssginSiteCRCCommand
{
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public Guid UserId { get; set; }
public DateTime? CreateTime { get; set; } = DateTime.Now;
public string UserRealName { get; set; } = String.Empty;
@@ -60,7 +60,7 @@ namespace IRaCIS.Core.Application.ViewModel
[NotDefault]
public Guid UserId { get; set; }
public Guid? SiteId { get; set; }
public Guid? TrialSiteId { get; set; }
public bool IsExternal { get; set; }
}
@@ -25,7 +25,7 @@ namespace IRaCIS.Application.Contracts
[ExcelFormat("yyyy-MM-dd HH:mm:ss")]
public DateTime? DeletedTime { get; set; }
public Guid? SiteId { get; set; }
public Guid? TrialSiteId { get; set; }
public string Phone { get; set; } = String.Empty;
public DateTime UpdateTime { get; set; }
@@ -186,7 +186,7 @@ namespace IRaCIS.Application.Contracts
public class SiteCRCCommand : UserTrialCommand
{
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public Guid UserTypeId { get; set; }
public string UserType { get; set; } = String.Empty;
@@ -229,7 +229,7 @@ namespace IRaCIS.Application.Contracts
{
public Guid Id { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public int? UserCount { get; set; }
@@ -304,7 +304,7 @@ namespace IRaCIS.Application.Contracts
public class SiteCRCQuery : TrialMaintenanceQuery
{
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
}
@@ -107,7 +107,7 @@ namespace IRaCIS.Application.Services
.WhereIf(param.UserTypeId != null, t => t.User.UserTypeId == param.UserTypeId)
.WhereIf(!string.IsNullOrWhiteSpace(param.UserRealName), t => (t.User.FullName).Contains(param.UserRealName))
.WhereIf(!string.IsNullOrWhiteSpace(param.OrganizationName), t => t.User.OrganizationName.Contains(param.OrganizationName))
.ProjectTo<AssginSiteCRCListDTO>(_mapper.ConfigurationProvider, new { siteId = param.SiteId });
.ProjectTo<AssginSiteCRCListDTO>(_mapper.ConfigurationProvider, new { trialSiteId = param.TrialSiteId });
return await query.ToPagedListAsync(param.PageIndex,
param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "UpdateTime" : param.SortField, param.Asc);
@@ -30,103 +30,6 @@ namespace IRaCIS.Core.Application.Services
}
#region
///// <summary>
///// Site用户列表导出
///// </summary>
///// <param name="param"></param>
///// <param name="_commonDocumentRepository"></param>
///// <returns></returns>
///// <exception cref="Exception"></exception>
//[HttpPost]
//[AllowAnonymous]
//public async Task<IActionResult> TrialSiteUserListExport(SiteCRCExportQueryDTO param, [FromServices] IRepository<CommonDocument> _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService)
//{
// var exportInfo = (await _trialRepository.Where(t => t.Id == param.TrialId).IgnoreQueryFilters().ProjectTo<ExcelExportInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
// exportInfo.List = await _trialSiteUserRepository.Where(t => t.TrialId == param.TrialId).IgnoreQueryFilters()
// .WhereIf(param.IsDeleted != null, t => t.IsDeleted == param.IsDeleted)
// .WhereIf(!string.IsNullOrWhiteSpace(param.SiteName), t => t.Site.SiteName.Contains(param.SiteName))
// .WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteAliasName),
// t => t.TrialSite.TrialSiteAliasName.Contains(param.TrialSiteAliasName))
// .WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteCode),
// t => t.TrialSite.TrialSiteCode.Contains(param.TrialSiteCode))
// .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator,
// t => t.UserId == _userInfo.Id)
// .WhereIf(!string.IsNullOrWhiteSpace(param.UserKeyInfo), t => (t.User.FullName).Contains(param.UserKeyInfo)
// || t.User.UserName.Contains(param.UserKeyInfo) || t.User.EMail.Contains(param.UserKeyInfo))
// .ProjectTo<SiteUserExportDTO>(_mapper.ConfigurationProvider).ToListAsync();
// exportInfo.IsEn_US = _userInfo.IsEn_Us;
// return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSiteUserList_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment,_dictionaryService,typeof(SiteUserExportDTO));
//}
///// <summary>
///// Site用户汇总表导出
///// </summary>
///// <param name="queryParam"></param>
///// <param name="_commonDocumentRepository"></param>
///// <param name="_trialSiteSurveyRepository"></param>
///// <param name="_trialSiteUserSurveyRepository"></param>
///// <param name="_dictionaryService"></param>
///// <returns></returns>
///// <exception cref="Exception"></exception>
//[HttpPost]
//[AllowAnonymous]
//public async Task<IActionResult> TrialSiteUserSummaryListExport(TrialSiteUserSurveyExportQueryDto queryParam,
// [FromServices] IRepository<CommonDocument> _commonDocumentRepository,
// [FromServices] IRepository<TrialSiteSurvey> _trialSiteSurveyRepository,
// [FromServices] IRepository<TrialSiteUserSurvey> _trialSiteUserSurveyRepository
// , [FromServices] IDictionaryService _dictionaryService
//)
//{
// var data = (await _trialRepository.Where(t => t.Id == queryParam.TrialId).IgnoreQueryFilters().ProjectTo<ExcelExportInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
// var groupSelectIdQuery =
// _trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId)
// .WhereIf(queryParam.SiteId != null, t => t.SiteId == queryParam.SiteId)
// .WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.UserName).Contains(queryParam.FormWriterKeyInfo) || t.Email.Contains(queryParam.FormWriterKeyInfo) || t.Phone.Contains(queryParam.FormWriterKeyInfo))
// .GroupBy(t => t.SiteId)
// .Select(g => g.OrderByDescending(u => u.CreateTime).Select(t => t.Id).First());
// var query = _trialSiteUserSurveyRepository
// .Where(t => groupSelectIdQuery.Contains(t.TrialSiteSurveyId))
// .WhereIf(queryParam.UserTypeId != null, t => t.UserTypeId == queryParam.UserTypeId)
// .WhereIf(queryParam.IsGenerateAccount != null, t => t.IsGenerateAccount == queryParam.IsGenerateAccount)
// .WhereIf(queryParam.TrialRoleNameId != null, t => t.TrialRoleNameId == queryParam.TrialRoleNameId)
// .WhereIf(queryParam.State != null && queryParam.State != TrialSiteUserStateEnum.OverTime, t => t.InviteState == queryParam.State)
// .WhereIf(queryParam.State != null && queryParam.State == TrialSiteUserStateEnum.OverTime, t => t.InviteState == TrialSiteUserStateEnum.HasSend && t.ExpireTime < DateTime.Now)
// .WhereIf(!string.IsNullOrEmpty(queryParam.UserName), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserName))
// .WhereIf(!string.IsNullOrEmpty(queryParam.OrganizationName), t => t.OrganizationName.Contains(queryParam.OrganizationName))
// .ProjectTo<TrialSiteUserSummaryDto>(_mapper.ConfigurationProvider);
// data.List = await query.ToListAsync();
// var exportInfo = data;
// exportInfo.IsEn_US = _userInfo.IsEn_Us;
// return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSiteUserSummary_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment,_dictionaryService,typeof(TrialSiteUserSummaryDto));
//}
#endregion
/// <summary>Pannel 进去 SiteTab </summary>
[HttpPost]
@@ -179,7 +82,7 @@ namespace IRaCIS.Core.Application.Services
[HttpGet, Route("{trialId:guid}/{siteId:guid}")]
public async Task<List<UserTrialDTO>> GetTrialSiteCRCList(Guid trialId, Guid siteId)
{
var query = _trialSiteUserRepository.Where(t => t.TrialId == trialId && t.SiteId == siteId).IgnoreQueryFilters()
var query = _trialSiteUserRepository.Where(t => t.TrialId == trialId && t.TrialSiteId == siteId).IgnoreQueryFilters()
.ProjectTo<UserTrialDTO>(_mapper.ConfigurationProvider);
return await query.ToListAsync();
@@ -241,28 +144,24 @@ namespace IRaCIS.Core.Application.Services
if (dbEntity == null) return Null404NotFound(dbEntity);
var trialId = dbEntity.TrialId;
var siteId = dbEntity.SiteId;
var trialSiteId = dbEntity.Id;
if (editTrialSiteCommand.IsDeleted)
{
//if (await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.SiteId == siteId))
//{
//---The site has been associated with CRC, and couldn't be deleted.
// return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteAssociatedCRC"]);
//}
if (await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId))
{
//---The site has been associated with CRC, and couldn't be deleted.
return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteAssociatedCRC"]);
}
if (await _repository.AnyAsync<Subject>(t => t.SiteId == siteId && t.TrialId == trialId))
if (await _repository.AnyAsync<Subject>(t => t.TrialSiteId == trialSiteId && t.TrialId == trialId))
{
//---The subjects has been added to this site, and couldn't be disable.
return ResponseOutput.NotOk(_localizer["TrialSite_ParticipantJoined"]);
}
//if (await _repository.AnyAsync<DicomStudy>(t => t.SiteId == siteId && t.TrialId == trialId))
//{
//---The site has been uploaded study, and couldn't be deleted.
// return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteUploadedData"]);
//}
}
@@ -387,24 +286,19 @@ namespace IRaCIS.Core.Application.Services
if (relation == null) return Null404NotFound(relation);
var trialId = relation.TrialId;
var siteId = relation.SiteId;
var trialSiteId = relation.Id;
if (await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.SiteId == siteId))
if (await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId))
{
//---The site has been associated with CRC, and couldn't be deleted.
return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteAssociatedCRC"]);
}
if (await _repository.AnyAsync<Subject>(t => t.SiteId == siteId && t.TrialId == trialId))
if (await _repository.AnyAsync<Subject>(t => t.TrialSiteId == trialSiteId && t.TrialId == trialId))
{
//---The subjects has been added to this site, and couldn't be deleted.
return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteAssociatedSubject"]);
}
if (await _repository.AnyAsync<DicomStudy>(t => t.SiteId == siteId && t.TrialId == trialId))
{
//---The site has been uploaded study, and couldn't be deleted.
return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteUploadedData"]);
}
await _repository.DeleteAsync(relation);
@@ -91,12 +91,12 @@ namespace IRaCIS.Core.Application.Service
.ForMember(t => t.UserType, u => u.MapFrom(t => t.User.UserTypeRole.UserTypeShortName));
CreateMap<User, TrialMaintenanceDTO>();
var siteId = Guid.Empty;
var trialSiteId = Guid.Empty;
CreateMap<TrialUser, AssginSiteCRCListDTO>().IncludeMembers(t => t.User)
.ForMember(d => d.UserRealName, u => u.MapFrom(s => s.User.FullName))
.ForMember(d => d.SiteId, u => u.MapFrom(t => siteId))
.ForMember(d => d.TrialSiteId, u => u.MapFrom(t => trialSiteId))
.ForMember(d => d.UserType, u => u.MapFrom(t => t.User.UserTypeRole.UserTypeShortName))
.ForMember(d => d.IsSelect, u => u.MapFrom(t => t.SiteList.Any(k => k.SiteId == siteId)));
.ForMember(d => d.IsSelect, u => u.MapFrom(t => t.SiteList.Any(k => k.TrialSiteId == trialSiteId)));
CreateMap<User, AssginSiteCRCListDTO>();
var trialId = Guid.Empty;
@@ -305,8 +305,8 @@ namespace IRaCIS.Core.Application.Service
.ForMember(t => t.ApprovalRequiredSiteCount, u =>
u.MapFrom(c => userTypeEnumInt == (int)UserTypeEnum.ProjectManager || userTypeEnumInt == (int)UserTypeEnum.APM ?
c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.SPMApproved).Select(t => t.SiteId).Distinct().Count()
: c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.CRCSubmitted).Select(t => t.SiteId).Distinct().Count())
c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.SPMApproved).Select(t => t.TrialSiteId).Distinct().Count()
: c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.CRCSubmitted).Select(t => t.TrialSiteId).Distinct().Count())
)
;