From c95ea8c5472ad63d8deae0a2de1a0726505f3de9 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Wed, 5 Jun 2024 14:54:37 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20CRO=20=20Sponsor=20?=
=?UTF-8?q?=E9=83=A8=E4=BD=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Service/Institution/CROService.cs | 4 +-
.../Service/Institution/SponsorService.cs | 4 +-
.../Service/TrialSiteUser/TrialService.cs | 37 +++++++++++++++++++
IRaCIS.Core.Domain/Institution/CRO.cs | 2 +
IRaCIS.Core.Domain/Institution/Sponsor.cs | 3 ++
5 files changed, 46 insertions(+), 4 deletions(-)
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/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; }
}
}