diff --git a/IRaCIS.Core.Application/Service/Institution/CROService.cs b/IRaCIS.Core.Application/Service/Institution/CROService.cs
index 9061b0b81..ea1617425 100644
--- a/IRaCIS.Core.Application/Service/Institution/CROService.cs
+++ b/IRaCIS.Core.Application/Service/Institution/CROService.cs
@@ -33,9 +33,9 @@ namespace IRaCIS.Application.Services
}
/// 根据CRO 名称查询所有CRO 列表
- public async Task> GetAllCROList(Guid? croId)
+ public async Task> GetAllCROList(Guid? trialId)
{
- return await _croRepository/*.Where(t => t.IsTrialLevel == false || t.Id == croId)*/.ProjectTo(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us }).ToListAsync();
+ return await _croRepository.Where(t => t.IsTrialLevel == false || t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us }).ToListAsync();
}
diff --git a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs
index b0b92a17e..f84172892 100644
--- a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs
+++ b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs
@@ -34,10 +34,10 @@ namespace IRaCIS.Application.Services
}
/// 分页获取申办方列表
- public async Task> GetAllSponsorList(Guid? sponsorId)
+ public async Task> GetAllSponsorList(Guid? trialId)
{
- var sponsorQueryable = _sponsorRepository/*.Where(t => t.IsTrialLevel == false || t.Id == sponsorId)*/.ProjectTo(_mapper.ConfigurationProvider,new { isEn_Us= _userInfo.IsEn_Us});
+ var sponsorQueryable = _sponsorRepository.Where(t => t.IsTrialLevel == false || t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider,new { isEn_Us= _userInfo.IsEn_Us});
return await sponsorQueryable.ToListAsync();
}
diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs
index fa82d77cc..2a12509de 100644
--- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs
+++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs
@@ -20,6 +20,7 @@ using IRaCIS.Core.Application.Service;
using DocumentFormat.OpenXml.Office.CustomUI;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Application.Contracts;
+using SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors;
namespace IRaCIS.Core.Application
{
@@ -946,10 +947,13 @@ namespace IRaCIS.Core.Application
var trialInfo = (await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialConfig.TrialId)).IfNullThrowException();
- trialConfig.Modalitys = $"|{String.Join('|', trialConfig.ModalityList)}|";
+ trialConfig.Modalitys = $"{String.Join('|', trialConfig.ModalityList)}";
_mapper.Map(trialConfig, trialInfo);
trialInfo.UpdateTime = DateTime.Now;
+
+ await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialConfig.TrialId && t.IsSigned == false, u => new ReadingQuestionCriterionTrial() { CriterionModalitys = trialConfig.Modalitys });
+
return ResponseOutput.Ok(await _repository.SaveChangesAsync());
}
@@ -1034,6 +1038,7 @@ namespace IRaCIS.Core.Application
if (trialConfig.TrialCriterionIds.Contains(item.Id))
{
item.IsConfirm = true;
+ item.CriterionModalitys = trialInfo.Modalitys;
}
else
{
@@ -1310,7 +1315,7 @@ namespace IRaCIS.Core.Application
public async Task>> GetTrialBodyPartList(Guid trialId)
{
- var list = await _trialRepository.Where(t => t.Id == trialId).SelectMany(t => t.TrialBodyPartList).Select(t=>new TrialBodyPartView() { Code=t.Code,Name=_userInfo.IsEn_Us?t.Name:t.NameCN}).ToListAsync();
+ var list = await _trialRepository.Where(t => t.Id == trialId).SelectMany(t => t.TrialBodyPartList).Select(t => new TrialBodyPartView() { Code = t.Code, Name = _userInfo.IsEn_Us ? t.Name : t.NameCN }).ToListAsync();
return ResponseOutput.Ok(list);
}
@@ -1318,10 +1323,24 @@ namespace IRaCIS.Core.Application
public async Task AddOrUpdateTrialBodyPart(AddOrUpdateTrialBodyPartCommand incommand)
{
+ var codeList = await _repository.Where(t => t.TrialId == incommand.TrialId).Select(t => t.Code).ToListAsync();
+
+
+ var newString = incommand.Code;
+ // 检查字符串是否在集合中存在,如果存在,则在后面加上一个数字
+ int count = 1;
+ while (codeList.Contains(newString))
+ {
+ newString = $"{newString}{count}";
+ count++;
+ }
+
+ incommand.Code = newString;
+
var exp = new EntityVerifyExp()
{
- VerifyExp = t => (t.Name.Equals(incommand.Name) || t.NameCN.Equals(incommand.NameCN)),
-
+ VerifyExp = t => (_userInfo.IsEn_Us ? t.Name.Equals(incommand.Name) : t.NameCN.Equals(incommand.NameCN)) && t.TrialId == incommand.TrialId,
+
VerifyMsg = _localizer["TrialBodyPart_DupName"]
};
@@ -1329,7 +1348,7 @@ namespace IRaCIS.Core.Application
- return ResponseOutput.Ok(cro.Id.ToString());
+ return ResponseOutput.Ok(cro.Id.ToString(), ApiResponseCodeEnum.NeedTips);
}
}
diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs
index 8097c71a5..504cef295 100644
--- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs
+++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs
@@ -11,6 +11,7 @@ using static IRaCIS.Core.Domain.Share.StaticData;
using Microsoft.AspNetCore.Authorization;
using System.Linq.Expressions;
using System.Linq;
+using IRaCIS.Core.Domain.Models;
namespace IRaCIS.Application.Services
{
@@ -221,6 +222,19 @@ namespace IRaCIS.Application.Services
var success = await _repository.SaveChangesAsync();
+ //维护CRO Sponsor
+ await DealSponsorAndCROAsync(trial);
+
+ //维护部位到项目表
+ var searchList = await _repository.Where(t => t.Parent.Code == "BodyPart" && t.ParentId != null && t.IsEnable).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
+
+ var needAddBodyPartList = searchList.Select(t => new TrialBodyPart() { Code = t.Code, Name = t.Value, NameCN = t.ValueCN });
+
+ needAddBodyPartList.ForEach(t => t.TrialId = trial.Id);
+
+ await _repository.AddRangeAsync(needAddBodyPartList);
+
+
_provider.Set(trial.Id.ToString(), StaticData.TrialState.TrialInitializing, TimeSpan.FromDays(7));
return ResponseOutput.Ok(trial);
@@ -268,12 +282,35 @@ namespace IRaCIS.Application.Services
trial.AttendedReviewerTypes = $"|{string.Join('|', updateModel.AttendedReviewerTypeEnumList.Select(x => ((int)x).ToString()).ToList())}|";
var success = await _repository.SaveChangesAsync();
+
+ //维护CRO Sponsor
+ await DealSponsorAndCROAsync(trial);
+
return ResponseOutput.Ok(trial);
}
}
+ private async Task DealSponsorAndCROAsync(Trial trial)
+ {
+ if (trial.SponsorId != null)
+ {
+ if (await _repository.AnyAsync(t => t.Id == trial.SponsorId && t.IsTrialLevel))
+ {
+ await _repository.BatchUpdateAsync(t => t.Id == trial.SponsorId, u => new Sponsor() { TrialId = trial.Id });
+ }
+ }
+
+ if (trial.CROId != null)
+ {
+ if (await _repository.AnyAsync(t => t.Id == trial.SponsorId && t.IsTrialLevel))
+ {
+ await _repository.BatchUpdateAsync(t => t.Id == trial.SponsorId, u => new Sponsor() { TrialId = trial.Id });
+ }
+ }
+ }
+
// TODO: 需要优化,嵌套两层 switch case ?
[NonDynamicMethod]
private async Task TrialExpeditedStatusChange(Guid trialId, int oldState, int newState)
diff --git a/IRaCIS.Core.Domain/Institution/CRO.cs b/IRaCIS.Core.Domain/Institution/CRO.cs
index aeaf02098..28037771b 100644
--- a/IRaCIS.Core.Domain/Institution/CRO.cs
+++ b/IRaCIS.Core.Domain/Institution/CRO.cs
@@ -17,5 +17,7 @@ namespace IRaCIS.Core.Domain.Models
public Guid CreateUserId { get; set; }
public Guid UpdateUserId { get; set; }
public DateTime UpdateTime { get; set; }
+
+ public Guid? TrialId { get; set; }
}
}
diff --git a/IRaCIS.Core.Domain/Institution/Sponsor.cs b/IRaCIS.Core.Domain/Institution/Sponsor.cs
index fcc862a89..571f89ba6 100644
--- a/IRaCIS.Core.Domain/Institution/Sponsor.cs
+++ b/IRaCIS.Core.Domain/Institution/Sponsor.cs
@@ -17,5 +17,8 @@ namespace IRaCIS.Core.Domain.Models
public Guid CreateUserId { get; set; } = Guid.Empty;
public DateTime UpdateTime { get; set; } = DateTime.Now;
public Guid UpdateUserId { get; set; } = Guid.Empty;
+
+
+ public Guid? TrialId { get; set; }
}
}