diff --git a/IRC.Core.SCP/IRC.Core.SCP.csproj b/IRC.Core.SCP/IRC.Core.SCP.csproj
index 0413c62d6..5db7866bd 100644
--- a/IRC.Core.SCP/IRC.Core.SCP.csproj
+++ b/IRC.Core.SCP/IRC.Core.SCP.csproj
@@ -7,8 +7,12 @@
+
+
+
+
diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs
index 86c09af4e..fe1f91e00 100644
--- a/IRC.Core.SCP/Service/CStoreSCPService.cs
+++ b/IRC.Core.SCP/Service/CStoreSCPService.cs
@@ -176,6 +176,13 @@ namespace IRaCIS.Core.SCP.Service
await _SCPImageUploadRepository.AddAsync(_upload, true);
+
+ var _studyRepository = _serviceProvider.GetService>();
+ //将检查设置为传输结束
+ await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true });
+
+ await _studyRepository.SaveChangesAndClearAllTrackingAsync();
+
await SendAssociationReleaseResponseAsync();
}
@@ -236,11 +243,11 @@ namespace IRaCIS.Core.SCP.Service
//奇怪的bug 上传的时候,用王捷修改的影像,会关闭,重新连接,导致检查id 丢失,然后状态不一致
if (exception == null)
{
- var _studyRepository = _serviceProvider.GetService>();
- //将检查设置为传输结束
- await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true });
+ //var _studyRepository = _serviceProvider.GetService>();
+ ////将检查设置为传输结束
+ //await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true });
- await _studyRepository.SaveChangesAndClearAllTrackingAsync();
+ //await _studyRepository.SaveChangesAndClearAllTrackingAsync();
}
Log.Logger.Warning($"连接关闭 {exception?.Message} {exception?.InnerException?.Message}");
diff --git a/IRC.Core.SCP/Service/OSSService.cs b/IRC.Core.SCP/Service/OSSService.cs
index eb34ec64f..4af37a247 100644
--- a/IRC.Core.SCP/Service/OSSService.cs
+++ b/IRC.Core.SCP/Service/OSSService.cs
@@ -14,48 +14,75 @@ using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
+using System.Text.Json.Serialization;
+using Minio.ApiEndpoints;
+using System.Reactive.Linq;
+using IRaCIS.Core.Domain.Share;
+using IRaCIS.Core.Infrastructure.NewtonsoftJson;
+using Amazon.Runtime;
+using Amazon.SecurityToken;
+using Amazon.SecurityToken.Model;
+using Amazon;
+using Amazon.S3;
+using Amazon.S3.Model;
+using MassTransit;
+using AlibabaCloud.SDK.Sts20150401;
namespace IRaCIS.Core.SCP
{
+ #region 绑定和返回模型
+
+ [LowerCamelCaseJson]
public class MinIOOptions : AWSOptions
{
- public int port { get; set; }
+ public int Port { get; set; }
}
+
public class AWSOptions
{
- public string endPoint { get; set; }
- public bool useSSL { get; set; }
- public string accessKey { get; set; }
- public string secretKey { get; set; }
- public string bucketName { get; set; }
- public string viewEndpoint { get; set; }
+ public string EndPoint { get; set; }
+ public bool UseSSL { get; set; }
+ public string AccessKeyId { get; set; }
+ public string RoleArn { get; set; }
+ public string SecretAccessKey { get; set; }
+ public string BucketName { get; set; }
+ public string ViewEndpoint { get; set; }
+ public int DurationSeconds { get; set; }
+ public string Region { get; set; }
}
public class AliyunOSSOptions
{
- public string regionId { get; set; }
- public string accessKeyId { get; set; }
- public string accessKeySecret { get; set; }
+ public string RegionId { get; set; }
+ public string AccessKeyId { get; set; }
+ public string AccessKeySecret { get; set; }
- public string internalEndpoint { get; set; }
+ public string InternalEndpoint { get; set; }
- public string endPoint { get; set; }
- public string bucketName { get; set; }
+ public string EndPoint { get; set; }
+ public string BucketName { get; set; }
- public string roleArn { get; set; }
+ public string RoleArn { get; set; }
+
+ public string Region { get; set; }
+
+ public string ViewEndpoint { get; set; }
+
+ public int DurationSeconds { get; set; }
- public string region { get; set; }
- public string viewEndpoint { get; set; }
}
public class ObjectStoreServiceOptions
{
public string ObjectStoreUse { get; set; }
+
public AliyunOSSOptions AliyunOSS { get; set; }
+
+
public MinIOOptions MinIO { get; set; }
public AWSOptions AWS { get; set; }
@@ -66,27 +93,46 @@ namespace IRaCIS.Core.SCP
{
public string ObjectStoreUse { get; set; }
- public AliyunOSSOptions AliyunOSS { get; set; }
+
+ public AliyunOSSTempToken AliyunOSS { get; set; }
public MinIOOptions MinIO { get; set; }
- public AWSOptions AWS { get; set; }
+ public AWSTempToken AWS { get; set; }
}
+ [LowerCamelCaseJson]
public class AliyunOSSTempToken
{
public string AccessKeyId { get; set; }
public string AccessKeySecret { get; set; }
- public string SecurityToken { get; set; }
- public string Expiration { get; set; }
+
+ public string EndPoint { get; set; }
+ public string BucketName { get; set; }
public string Region { get; set; }
- public string BucketName { get; set; }
+
public string ViewEndpoint { get; set; }
+
+ public string SecurityToken { get; set; }
+ public DateTime Expiration { get; set; }
+
+
}
-
+ [LowerCamelCaseJson]
+ public class AWSTempToken
+ {
+ public string Region { get; set; }
+ public string SessionToken { get; set; }
+ public string EndPoint { get; set; }
+ public string AccessKeyId { get; set; }
+ public string SecretAccessKey { get; set; }
+ public string BucketName { get; set; }
+ public string ViewEndpoint { get; set; }
+ public DateTime Expiration { get; set; }
+ }
public enum ObjectStoreUse
{
@@ -95,6 +141,10 @@ namespace IRaCIS.Core.SCP
AWS = 2,
}
+ #endregion
+
+ // aws 参考链接 https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/S3/S3_Basics
+
public interface IOSSService
{
public Task UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true);
@@ -106,6 +156,9 @@ namespace IRaCIS.Core.SCP
public Task GetSignedUrl(string ossRelativePath);
+ public Task DeleteFromPrefix(string prefix);
+
+ public Task GetObjectStoreTempToken();
}
@@ -113,10 +166,16 @@ namespace IRaCIS.Core.SCP
{
public ObjectStoreServiceOptions ObjectStoreServiceOptions { get; set; }
+ private AliyunOSSTempToken AliyunOSSTempToken { get; set; }
+
+ private AWSTempToken AWSTempToken { get; set; }
+
public OSSService(IOptionsMonitor options)
{
ObjectStoreServiceOptions = options.CurrentValue;
+
+ GetObjectStoreTempToken().GetAwaiter().GetResult();
}
///
@@ -130,8 +189,6 @@ namespace IRaCIS.Core.SCP
public async Task UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true)
{
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}" : $"{oosFolderPath}/{fileRealName}";
- //var ossRelativePath = $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}";
- //var ossRelativePath = oosFolderPath + "/" + fileRealName;
try
{
@@ -148,12 +205,12 @@ namespace IRaCIS.Core.SCP
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
- var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
+ var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
// 上传文件
- var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, memoryStream);
+ var result = _ossClient.PutObject(aliConfig.BucketName, ossRelativePath, memoryStream);
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
@@ -161,12 +218,12 @@ namespace IRaCIS.Core.SCP
var minIOConfig = ObjectStoreServiceOptions.MinIO;
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
+ var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
+ .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
.Build();
var putObjectArgs = new PutObjectArgs()
- .WithBucket(minIOConfig.bucketName)
+ .WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithStreamData(memoryStream)
.WithObjectSize(memoryStream.Length);
@@ -175,20 +232,29 @@ namespace IRaCIS.Core.SCP
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
{
- var minIOConfig = ObjectStoreServiceOptions.AWS;
+ var awsConfig = ObjectStoreServiceOptions.AWS;
+
+ var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
- .Build();
- var putObjectArgs = new PutObjectArgs()
- .WithBucket(minIOConfig.bucketName)
- .WithObject(ossRelativePath)
- .WithStreamData(memoryStream)
- .WithObjectSize(memoryStream.Length);
+ //提供awsEndPoint(域名)进行访问配置
+ var clientConfig = new AmazonS3Config
+ {
+ RegionEndpoint = RegionEndpoint.USEast1,
+ UseHttp = true,
+ };
- await minioClient.PutObjectAsync(putObjectArgs);
+ var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
+
+ var putObjectRequest = new Amazon.S3.Model.PutObjectRequest()
+ {
+ BucketName = awsConfig.BucketName,
+ InputStream = memoryStream,
+ Key = ossRelativePath,
+ };
+
+ await amazonS3Client.PutObjectAsync(putObjectRequest);
}
else
{
@@ -216,6 +282,7 @@ namespace IRaCIS.Core.SCP
///
///
///
+ ///
///
///
public async Task UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true)
@@ -225,17 +292,14 @@ namespace IRaCIS.Core.SCP
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}";
- //var ossRelativePath = oosFolderPath + "/" + localFileName;
-
-
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
- var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
+ var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
// 上传文件
- var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, localFilePath);
+ var result = _ossClient.PutObject(aliConfig.BucketName, ossRelativePath, localFilePath);
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
@@ -243,12 +307,12 @@ namespace IRaCIS.Core.SCP
var minIOConfig = ObjectStoreServiceOptions.MinIO;
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
+ var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
+ .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
.Build();
var putObjectArgs = new PutObjectArgs()
- .WithBucket(minIOConfig.bucketName)
+ .WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithFileName(localFilePath);
@@ -256,19 +320,29 @@ namespace IRaCIS.Core.SCP
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
{
- var minIOConfig = ObjectStoreServiceOptions.AWS;
+ var awsConfig = ObjectStoreServiceOptions.AWS;
+ // 提供awsAccessKeyId和awsSecretAccessKey构造凭证
+ var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
- .Build();
+ //提供awsEndPoint(域名)进行访问配置
+ var clientConfig = new AmazonS3Config
+ {
+ RegionEndpoint = RegionEndpoint.USEast1,
+ UseHttp = true,
+ };
- var putObjectArgs = new PutObjectArgs()
- .WithBucket(minIOConfig.bucketName)
- .WithObject(ossRelativePath)
- .WithFileName(localFilePath);
+ var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
+
+ var putObjectRequest = new Amazon.S3.Model.PutObjectRequest()
+ {
+ BucketName = awsConfig.BucketName,
+ FilePath = localFilePath,
+ Key = ossRelativePath,
+ };
+
+ await amazonS3Client.PutObjectAsync(putObjectRequest);
- await minioClient.PutObjectAsync(putObjectArgs);
}
else
{
@@ -291,10 +365,10 @@ namespace IRaCIS.Core.SCP
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
- var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
+ var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
// 上传文件
- var result = _ossClient.GetObject(aliConfig.bucketName, ossRelativePath);
+ var result = _ossClient.GetObject(aliConfig.BucketName, ossRelativePath);
// 将下载的文件流保存到本地文件
using (var fs = File.OpenWrite(localFilePath))
@@ -308,12 +382,12 @@ namespace IRaCIS.Core.SCP
{
var minIOConfig = ObjectStoreServiceOptions.MinIO;
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
+ var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
+ .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
.Build();
var getObjectArgs = new GetObjectArgs()
- .WithBucket(minIOConfig.bucketName)
+ .WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithFile(localFilePath);
@@ -322,18 +396,30 @@ namespace IRaCIS.Core.SCP
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
{
- var minIOConfig = ObjectStoreServiceOptions.AWS;
+ var awsConfig = ObjectStoreServiceOptions.AWS;
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
- .Build();
+ // 提供awsAccessKeyId和awsSecretAccessKey构造凭证
+ var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
+
+ //提供awsEndPoint(域名)进行访问配置
+ var clientConfig = new AmazonS3Config
+ {
+ RegionEndpoint = RegionEndpoint.USEast1,
+ UseHttp = true,
+ };
+
+ var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
+
+ var getObjectArgs = new Amazon.S3.Model.GetObjectRequest()
+ {
+ BucketName = awsConfig.BucketName,
+ Key = ossRelativePath,
+ };
+
+
+ await (await amazonS3Client.GetObjectAsync(getObjectArgs)).WriteResponseStreamToFileAsync(localFilePath, true, CancellationToken.None);
- var getObjectArgs = new GetObjectArgs()
- .WithBucket(minIOConfig.bucketName)
- .WithObject(ossRelativePath)
- .WithFile(localFilePath);
- await minioClient.GetObjectAsync(getObjectArgs);
}
else
{
@@ -363,10 +449,10 @@ namespace IRaCIS.Core.SCP
{
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
- var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
+ var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
// 生成签名URL。
- var req = new GeneratePresignedUriRequest(aliConfig.bucketName, ossRelativePath, SignHttpMethod.Get)
+ var req = new GeneratePresignedUriRequest(aliConfig.BucketName, ossRelativePath, SignHttpMethod.Get)
{
// 设置签名URL过期时间,默认值为3600秒。
Expiration = DateTime.Now.AddHours(1),
@@ -380,13 +466,13 @@ namespace IRaCIS.Core.SCP
{
var minIOConfig = ObjectStoreServiceOptions.MinIO;
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
+ var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
+ .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
.Build();
var args = new PresignedGetObjectArgs()
- .WithBucket(minIOConfig.bucketName)
+ .WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithExpiry(3600)
/*.WithHeaders(reqParams)*/;
@@ -403,18 +489,27 @@ namespace IRaCIS.Core.SCP
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
{
- var minIOConfig = ObjectStoreServiceOptions.AWS;
+ var awsConfig = ObjectStoreServiceOptions.AWS;
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}")
- .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL)
- .Build();
- var args = new PresignedGetObjectArgs()
- .WithBucket(minIOConfig.bucketName)
- .WithObject(ossRelativePath)
- .WithExpiry(3600);
+ // 提供awsAccessKeyId和awsSecretAccessKey构造凭证
+ var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
- var presignedUrl = await minioClient.PresignedGetObjectAsync(args);
+ //提供awsEndPoint(域名)进行访问配置
+ var clientConfig = new AmazonS3Config
+ {
+ RegionEndpoint = RegionEndpoint.USEast1,
+ UseHttp = true,
+ };
+
+ var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
+
+ var presignedUrl = await amazonS3Client.GetPreSignedURLAsync(new GetPreSignedUrlRequest()
+ {
+ BucketName = awsConfig.BucketName,
+ Key = ossRelativePath,
+ Expires = DateTime.UtcNow.AddMinutes(120)
+ });
Uri uri = new Uri(presignedUrl);
@@ -435,8 +530,248 @@ namespace IRaCIS.Core.SCP
}
}
+
+ ///
+ /// 删除某个目录的文件
+ ///
+ ///
+ ///
+ public async Task DeleteFromPrefix(string prefix)
+ {
+ if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
+ {
+ var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
+
+ var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
+
+
+ try
+ {
+ ObjectListing objectListing = null;
+ string nextMarker = null;
+ do
+ {
+ // 使用 prefix 模拟目录结构,设置 MaxKeys 和 NextMarker
+ objectListing = _ossClient.ListObjects(new Aliyun.OSS.ListObjectsRequest(aliConfig.BucketName)
+ {
+ Prefix = prefix,
+ MaxKeys = 1000,
+ Marker = nextMarker
+ });
+
+ List keys = objectListing.ObjectSummaries.Select(t => t.Key).ToList();
+
+ // 删除获取到的文件
+ if (keys.Count > 0)
+ {
+ _ossClient.DeleteObjects(new Aliyun.OSS.DeleteObjectsRequest(aliConfig.BucketName, keys, false));
+ }
+
+ // 设置 NextMarker 以获取下一页的数据
+ nextMarker = objectListing.NextMarker;
+
+ } while (objectListing.IsTruncated);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Error: {ex.Message}");
+ }
+
+
+ }
+ else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
+ {
+ var minIOConfig = ObjectStoreServiceOptions.MinIO;
+
+
+ var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
+ .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
+ .Build();
+
+
+ var listArgs = new ListObjectsArgs().WithBucket(minIOConfig.BucketName).WithPrefix(prefix).WithRecursive(true);
+
+
+
+ // 创建一个空列表用于存储对象键
+ var objects = new List();
+
+ // 使用 await foreach 来异步迭代对象列表
+ await foreach (var item in minioClient.ListObjectsEnumAsync(listArgs))
+ {
+ objects.Add(item.Key);
+ }
+
+
+ if (objects.Count > 0)
+ {
+ var objArgs = new RemoveObjectsArgs()
+ .WithBucket(minIOConfig.BucketName)
+ .WithObjects(objects);
+
+ // 删除对象
+ await minioClient.RemoveObjectsAsync(objArgs);
+ }
+
+
+
+ }
+ else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
+ {
+
+ var awsConfig = ObjectStoreServiceOptions.AWS;
+
+
+ // 提供awsAccessKeyId和awsSecretAccessKey构造凭证
+ var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
+
+ //提供awsEndPoint(域名)进行访问配置
+ var clientConfig = new AmazonS3Config
+ {
+ RegionEndpoint = RegionEndpoint.USEast1,
+ UseHttp = true,
+ };
+
+ var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
+
+ // 列出指定前缀下的所有对象
+ var listObjectsRequest = new ListObjectsV2Request
+ {
+ BucketName = awsConfig.BucketName,
+ Prefix = prefix
+ };
+
+ var listObjectsResponse = await amazonS3Client.ListObjectsV2Async(listObjectsRequest);
+
+ if (listObjectsResponse.S3Objects.Count > 0)
+ {
+ // 准备删除请求
+ var deleteObjectsRequest = new Amazon.S3.Model.DeleteObjectsRequest
+ {
+ BucketName = awsConfig.BucketName,
+ Objects = new List()
+ };
+
+ foreach (var s3Object in listObjectsResponse.S3Objects)
+ {
+ deleteObjectsRequest.Objects.Add(new KeyVersion
+ {
+ Key = s3Object.Key
+ });
+ }
+
+ // 批量删除对象
+ var deleteObjectsResponse = await amazonS3Client.DeleteObjectsAsync(deleteObjectsRequest);
+ }
+
+
+
+ }
+ else
+ {
+ throw new BusinessValidationFailedException("未定义的存储介质类型");
+ }
+ }
+
+
+
+
+ public async Task GetObjectStoreTempToken()
+ {
+ var ossOptions = ObjectStoreServiceOptions.AliyunOSS;
+
+ if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
+ {
+ var client = new Client(new AlibabaCloud.OpenApiClient.Models.Config()
+ {
+ AccessKeyId = ossOptions.AccessKeyId,
+ AccessKeySecret = ossOptions.AccessKeySecret,
+ //AccessKeyId = "LTAI5tJV76pYX5yPg1N9QVE8",
+ //AccessKeySecret = "roRNLa9YG1of4pYruJGCNKBXEWTAWa",
+
+ Endpoint = "sts.cn-hangzhou.aliyuncs.com"
+ });
+
+ var assumeRoleRequest = new AlibabaCloud.SDK.Sts20150401.Models.AssumeRoleRequest();
+ // 将设置为自定义的会话名称,例如oss-role-session。
+ assumeRoleRequest.RoleSessionName = $"session-name-{NewId.NextGuid()}";
+ // 将替换为拥有上传文件到指定OSS Bucket权限的RAM角色的ARN。
+ assumeRoleRequest.RoleArn = ossOptions.RoleArn;
+ //assumeRoleRequest.RoleArn = "acs:ram::1899121822495495:role/webdirect";
+ assumeRoleRequest.DurationSeconds = ossOptions.DurationSeconds;
+ var runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
+ var response = client.AssumeRoleWithOptions(assumeRoleRequest, runtime);
+ var credentials = response.Body.Credentials;
+
+ var tempToken = new AliyunOSSTempToken()
+ {
+ AccessKeyId = credentials.AccessKeyId,
+ AccessKeySecret = credentials.AccessKeySecret,
+
+ //转为服务器时区,最后统一转为客户端时区
+ Expiration = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse(credentials.Expiration), TimeZoneInfo.Local),
+ SecurityToken = credentials.SecurityToken,
+
+
+ Region = ossOptions.Region,
+ BucketName = ossOptions.BucketName,
+ EndPoint = ossOptions.EndPoint,
+ ViewEndpoint = ossOptions.ViewEndpoint,
+
+ };
+
+ AliyunOSSTempToken = tempToken;
+
+ return new ObjectStoreDTO() { ObjectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse, AliyunOSS = tempToken };
+ }
+ else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
+ {
+ return new ObjectStoreDTO() { ObjectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse, MinIO = ObjectStoreServiceOptions.MinIO };
+ }
+ else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
+ {
+ var awsOptions = ObjectStoreServiceOptions.AWS;
+
+ //aws 临时凭证
+ // 创建 STS 客户端
+ var stsClient = new AmazonSecurityTokenServiceClient(awsOptions.AccessKeyId, awsOptions.SecretAccessKey);
+
+ // 使用 AssumeRole 请求临时凭证
+ var assumeRoleRequest = new AssumeRoleRequest
+ {
+
+ RoleArn = awsOptions.RoleArn, // 角色 ARN
+ RoleSessionName = $"session-name-{NewId.NextGuid()}",
+ DurationSeconds = awsOptions.DurationSeconds // 临时凭证有效期
+ };
+
+ var assumeRoleResponse = await stsClient.AssumeRoleAsync(assumeRoleRequest);
+
+ var credentials = assumeRoleResponse.Credentials;
+
+ var tempToken = new AWSTempToken()
+ {
+ AccessKeyId = credentials.AccessKeyId,
+ SecretAccessKey = credentials.SecretAccessKey,
+ SessionToken = credentials.SessionToken,
+ Expiration = credentials.Expiration,
+ Region = awsOptions.Region,
+ BucketName = awsOptions.BucketName,
+ EndPoint = awsOptions.EndPoint,
+ ViewEndpoint = awsOptions.ViewEndpoint,
+
+ };
+
+ AWSTempToken = tempToken;
+ return new ObjectStoreDTO() { ObjectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse, AWS = tempToken };
+ }
+ else
+ {
+ throw new BusinessValidationFailedException("未定义的存储介质类型");
+ }
+ }
+
}
-
}
diff --git a/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json b/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json
index 218d5a2c8..9d7cf60ac 100644
--- a/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json
+++ b/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json
@@ -9,15 +9,16 @@
"ObjectStoreService": {
"ObjectStoreUse": "AliyunOSS",
"AliyunOSS": {
- "regionId": "cn-shanghai",
- "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
- "endpoint": "https://oss-cn-shanghai.aliyuncs.com",
- "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ",
- "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio",
- "bucketName": "zy-irc-store",
- "roleArn": "acs:ram::1899121822495495:role/oss-upload",
- "viewEndpoint": "https://zy-irc-cache.oss-cn-shanghai.aliyuncs.com",
- "region": "oss-cn-shanghai"
+ "RegionId": "cn-shanghai",
+ "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
+ "EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
+ "AccessKeyId": "LTAI5tNRTsqL6aWmHkDmTwoH",
+ "AccessKeySecret": "7mtGz3qrYWI6JMMBZiLeC119VWicZH",
+ "RoleArn": "acs:ram::1899121822495495:role/irc-oss-access",
+ "BucketName": "zy-irc-store",
+ "ViewEndpoint": "https://zy-irc-cache.oss-cn-shanghai.aliyuncs.com",
+ "Region": "oss-cn-shanghai",
+ "DurationSeconds": 7200
}
},
diff --git a/IRC.Core.SCP/appsettings.Test_IRC_SCP.json b/IRC.Core.SCP/appsettings.Test_IRC_SCP.json
index 077a9194a..022a47cd3 100644
--- a/IRC.Core.SCP/appsettings.Test_IRC_SCP.json
+++ b/IRC.Core.SCP/appsettings.Test_IRC_SCP.json
@@ -9,15 +9,16 @@
"ObjectStoreService": {
"ObjectStoreUse": "AliyunOSS",
"AliyunOSS": {
- "regionId": "cn-shanghai",
- "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
- "endPoint": "https://oss-cn-shanghai.aliyuncs.com",
- "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ",
- "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio",
- "bucketName": "zy-irc-test-store",
- "roleArn": "acs:ram::1899121822495495:role/oss-upload",
- "viewEndpoint": "https://zy-irc-test-store.oss-cn-shanghai.aliyuncs.com",
- "region": "oss-cn-shanghai"
+ "RegionId": "cn-shanghai",
+ "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
+ "EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
+ "AccessKeyId": "LTAI5tRRZehUp2V9pyTPtAJm",
+ "AccessKeySecret": "FLizxkHsMm4CGYHtkV8E3PNJJZU7oV",
+ "RoleArn": "acs:ram::1899121822495495:role/dev-oss-access",
+ "BucketName": "zy-irc-test-store",
+ "ViewEndpoint": "https://zy-irc-test-store.oss-cn-shanghai.aliyuncs.com",
+ "Region": "oss-cn-shanghai",
+ "DurationSeconds": 7200
},
"MinIO": {
@@ -28,16 +29,8 @@
"secretKey": "TzgvyA3zGXMUnpilJNUlyMYHfosl1hBMl6lxPmjy",
"bucketName": "hir-test",
"viewEndpoint": "http://106.14.89.110:9001/hir-test/"
- },
-
- "AWS": {
- "endPoint": "s3.us-east-1.amazonaws.com",
- "useSSL": false,
- "accessKey": "AKIAZQ3DRSOHFPJJ6FEU",
- "secretKey": "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",
- "bucketName": "ei-irc-test-store",
- "viewEndpoint": "https://ei-irc-test-store.s3.amazonaws.com/"
}
+
},
"ConnectionStrings": {
diff --git a/IRC.Core.SCP/appsettings.US_Prod_SCP.json b/IRC.Core.SCP/appsettings.US_Prod_SCP.json
index 3387edb1d..e56626eb7 100644
--- a/IRC.Core.SCP/appsettings.US_Prod_SCP.json
+++ b/IRC.Core.SCP/appsettings.US_Prod_SCP.json
@@ -9,12 +9,15 @@
"ObjectStoreService": {
"ObjectStoreUse": "AWS",
"AWS": {
- "endPoint": "s3.us-east-1.amazonaws.com",
- "useSSL": true,
- "accessKey": "AKIAW3MEAFJX5P32P6NA",
- "secretKey": "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",
- "bucketName": "ei-med-s3-lili-store",
- "viewEndpoint": "https://ei-med-s3-lili-store.s3.amazonaws.com/"
+ "Region": "us-east-1",
+ "EndPoint": "s3.us-east-1.amazonaws.com",
+ "UseSSL": true,
+ "RoleArn": "arn:aws:iam::471112624751:role/lili_s3_access",
+ "AccessKeyId": "AKIAW3MEAFJXZ2TZK7GM",
+ "SecretAccessKey": "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",
+ "BucketName": "ei-med-s3-lili-uat-store",
+ "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/",
+ "DurationSeconds": 7200
}
},
"ConnectionStrings": {
diff --git a/IRC.Core.SCP/appsettings.US_Uat_SCP.json b/IRC.Core.SCP/appsettings.US_Uat_SCP.json
index 1d15fadf7..28a51b21f 100644
--- a/IRC.Core.SCP/appsettings.US_Uat_SCP.json
+++ b/IRC.Core.SCP/appsettings.US_Uat_SCP.json
@@ -9,17 +9,20 @@
"ObjectStoreService": {
"ObjectStoreUse": "AWS",
"AWS": {
- "endPoint": "s3.us-east-1.amazonaws.com",
- "useSSL": true,
- "accessKey": "AKIAW3MEAFJXUO6XYFYN",
- "secretKey": "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",
- "bucketName": "ei-med-s3-lili-uat-store",
- "viewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/"
+ "Region": "us-east-1",
+ "EndPoint": "s3.us-east-1.amazonaws.com",
+ "UseSSL": true,
+ "RoleArn": "arn:aws:iam::471112624751:role/uat_s3_access",
+ "AccessKeyId": "AKIAW3MEAFJX7IPXISP4",
+ "SecretAccessKey": "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",
+ "BucketName": "ei-med-s3-lili-uat-store",
+ "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/",
+ "DurationSeconds": 7200
}
},
"ConnectionStrings": {
- "RemoteNew": "Server=47.117.164.182,1434;Database=Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
- "Hangfire": "Server=47.117.164.182,1434;Database=Uat_IRC.Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
+ "RemoteNew": "Server=us-mssql-service,1433;Database=US_Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
+ "Hangfire": "Server=us-mssql-service,1433;Database=US_Uat_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
},
"DicomSCPServiceConfig": {
"CalledAEList": [
diff --git a/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json b/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json
index 18a92a53b..2d2fa6c9e 100644
--- a/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json
+++ b/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json
@@ -9,15 +9,16 @@
"ObjectStoreService": {
"ObjectStoreUse": "AliyunOSS",
"AliyunOSS": {
- "regionId": "cn-shanghai",
- "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
- "endpoint": "https://oss-cn-shanghai.aliyuncs.com",
- "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ",
- "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio",
- "bucketName": "zy-irc-uat-store",
- "roleArn": "acs:ram::1899121822495495:role/oss-upload",
- "viewEndpoint": "https://zy-irc-uat-store.oss-cn-shanghai.aliyuncs.com",
- "region": "oss-cn-shanghai"
+ "RegionId": "cn-shanghai",
+ "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
+ "EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
+ "AccessKeyId": "LTAI5tRRZehUp2V9pyTPtAJm",
+ "AccessKeySecret": "FLizxkHsMm4CGYHtkV8E3PNJJZU7oV",
+ "RoleArn": "acs:ram::1899121822495495:role/dev-oss-access",
+ "BucketName": "zy-irc-uat-store",
+ "ViewEndpoint": "https://zy-irc-uat-store.oss-cn-shanghai.aliyuncs.com",
+ "Region": "oss-cn-shanghai",
+ "DurationSeconds": 7200
}
},
"ConnectionStrings": {
diff --git a/IRaCIS.Core.API/1Test.cs b/IRaCIS.Core.API/1Test.cs
deleted file mode 100644
index f7567c3ca..000000000
--- a/IRaCIS.Core.API/1Test.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using Microsoft.EntityFrameworkCore;
-
-namespace EFSaving.Concurrency
-{
- public class Sample
- {
- public static void Run()
- {
- // Ensure database is created and has a person in it
- using (var setupContext = new PersonContext())
- {
- setupContext.Database.EnsureDeleted();
- setupContext.Database.EnsureCreated();
-
- setupContext.People.Add(new Person { FirstName = "John", LastName = "Doe" });
- setupContext.SaveChanges();
- }
-
- #region ConcurrencyHandlingCode
- using var context = new PersonContext();
- // Fetch a person from database and change phone number
- var person = context.People.Single(p => p.PersonId == 1);
- person.PhoneNumber = "555-555-5555";
-
- // Change the person's name in the database to simulate a concurrency conflict
- context.Database.ExecuteSqlRaw(
- "UPDATE dbo.People SET FirstName = 'Jane' WHERE PersonId = 1");
-
- var saved = false;
- while (!saved)
- {
- try
- {
- // Attempt to save changes to the database
- context.SaveChanges();
- saved = true;
- }
- catch (DbUpdateConcurrencyException ex)
- {
- foreach (var entry in ex.Entries)
- {
- if (entry.Entity is Person)
- {
- var proposedValues = entry.CurrentValues;
- var databaseValues = entry.GetDatabaseValues();
-
- foreach (var property in proposedValues.Properties)
- {
- var proposedValue = proposedValues[property];
- var databaseValue = databaseValues[property];
-
- // TODO: decide which value should be written to database
- // proposedValues[property] = ;
- }
-
- // Refresh original values to bypass next concurrency check
- entry.OriginalValues.SetValues(databaseValues);
- }
- else
- {
- throw new NotSupportedException(
- "Don't know how to handle concurrency conflicts for "
- + entry.Metadata.Name);
- }
- }
- }
- }
- #endregion
- }
-
- public class PersonContext : DbContext
- {
- public DbSet People { get; set; }
-
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- // Requires NuGet package Microsoft.EntityFrameworkCore.SqlServer
- optionsBuilder.UseSqlServer(
- @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Concurrency;Trusted_Connection=True");
- }
- }
-
- public class Person
- {
- public int PersonId { get; set; }
-
- [ConcurrencyCheck]
- public string FirstName { get; set; }
-
- [ConcurrencyCheck]
- public string LastName { get; set; }
-
- public string PhoneNumber { get; set; }
- }
- }
-}
\ No newline at end of file
diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs
index 000f81c25..203a4fc97 100644
--- a/IRaCIS.Core.API/Controllers/ExtraController.cs
+++ b/IRaCIS.Core.API/Controllers/ExtraController.cs
@@ -37,6 +37,7 @@ using Amazon.SecurityToken.Model;
using Amazon.SecurityToken;
using Amazon;
using AssumeRoleRequest = Amazon.SecurityToken.Model.AssumeRoleRequest;
+using AutoMapper;
namespace IRaCIS.Api.Controllers
{
@@ -109,8 +110,12 @@ namespace IRaCIS.Api.Controllers
[FromServices] ITokenService _tokenService,
[FromServices] IReadingImageTaskService readingImageTaskService,
[FromServices] IOptionsMonitor _verifyConfig,
+ [FromServices] IOptionsMonitor _emailConfig,
+
[FromServices] IMailVerificationService _mailVerificationService)
{
+ var emailConfig = _emailConfig.CurrentValue;
+ var companyInfo = new SystemEmailSendConfigView() { CompanyName = emailConfig.CompanyName, CompanyNameCN = emailConfig.CompanyNameCN, CompanyShortName = emailConfig.CompanyShortName, CompanyShortNameCN = emailConfig.CompanyShortNameCN };
//MFA 邮箱验证 前端传递用户Id 和MFACode
if (loginUser.UserId != null && _verifyConfig.CurrentValue.OpenLoginMFA)
@@ -143,10 +148,11 @@ namespace IRaCIS.Api.Controllers
// 验证阅片休息时间
await readingImageTaskService.ResetReadingRestTime(userId);
- await _fusionCache.SetAsync(userId.ToString(), loginReturn.JWTStr, TimeSpan.FromDays(7));
+ await _fusionCache.SetAsync(CacheKeys.UserToken(userId), loginReturn.JWTStr, TimeSpan.FromDays(7));
- await _fusionCache.SetAsync($"{userId.ToString()}_Online", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes));
+ await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(userId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes));
+ loginReturn.CompanyInfo = companyInfo;
return ResponseOutput.Ok(loginReturn);
}
@@ -274,6 +280,8 @@ namespace IRaCIS.Api.Controllers
}
}
+
+ returnModel.Data.CompanyInfo = companyInfo;
return returnModel;
}
@@ -283,8 +291,14 @@ namespace IRaCIS.Api.Controllers
}
+ [AllowAnonymous]
+ [HttpGet, Route("user/getPublicKey")]
+ public IResponseOutput GetPublicKey([FromServices] IOptionsMonitor _IRCEncreptOption)
+ {
+ //var pemPublicKey = Encoding.UTF8.GetString(Convert.FromBase64String(_IRCEncreptOption.CurrentValue.Base64RSAPublicKey));
-
+ return ResponseOutput.Ok(_IRCEncreptOption.CurrentValue.Base64RSAPublicKey);
+ }
[HttpGet, Route("imageShare/ShareImage")]
@@ -312,7 +326,7 @@ namespace IRaCIS.Api.Controllers
var result = await _oSSService.GetObjectStoreTempToken();
- result.AWS =await GetAWSTemToken(options.CurrentValue);
+ result.AWS = await GetAWSTemToken(options.CurrentValue);
return ResponseOutput.Ok(result);
diff --git a/IRaCIS.Core.API/IRaCIS - Backup.Core.API.csproj b/IRaCIS.Core.API/IRaCIS - Backup.Core.API.csproj
deleted file mode 100644
index b14f8c9bf..000000000
--- a/IRaCIS.Core.API/IRaCIS - Backup.Core.API.csproj
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
- net6.0
- false
- 354572d4-9e15-4099-807c-63a2d29ff9f2
- default
- Linux
-
-
-
- .\IRaCIS.Core.API.xml
- 1701;1702;1591;
- ..\bin\
-
-
-
- bin\Release\IRaCIS.Core.API.xml
- bin\Release\
- 1701;1702;1591
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Client
-
-
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Always
-
-
-
-
-
-
-
diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj
index d73c5fbc1..1a7f28ec4 100644
--- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj
+++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj
@@ -96,6 +96,12 @@
+
+
+ Always
+
+
+
diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml
index 6573bf84a..068efa5a9 100644
--- a/IRaCIS.Core.API/IRaCIS.Core.API.xml
+++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml
@@ -29,7 +29,7 @@
-
+
系统用户登录接口[New]
@@ -375,11 +375,6 @@
序列化成员
-
-
- 废弃,没用
-
-
对称可逆加密
diff --git a/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs b/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs
deleted file mode 100644
index c3c71da2a..000000000
--- a/IRaCIS.Core.API/Middleware/TimeZoneAdjustmentMiddleware.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.Primitives;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using System.Threading.Tasks;
-
-///
-/// 废弃,没用
-///
-public class TimeZoneAdjustmentMiddleware
-{
- private readonly RequestDelegate _next;
-
- public TimeZoneAdjustmentMiddleware(RequestDelegate next)
- {
- _next = next;
- }
-
- public async Task Invoke(HttpContext context)
- {
- if (string.IsNullOrEmpty(context.Request.ContentType))
- {
- // 请求没有内容体,可能是一个没有请求体的请求,比如 GET 请求
- await _next(context);
- return;
- }
-
-
- var timeZoneId = "Asia/Shanghai"; // 客户端默认时区
-
- var timeZoneIdHeaderValue = context.Request.Headers["TimeZoneId"];
-
- if (!string.IsNullOrEmpty(timeZoneIdHeaderValue))
- {
- timeZoneId = timeZoneIdHeaderValue;
- }
-
- var timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
-
-
-
- // 处理 JSON 请求体中的时间字段
- if (context.Request.ContentType.StartsWith("application/json"))
- {
- var requestBody = await new StreamReader(context.Request.Body).ReadToEndAsync();
-
- // 使用 JSON.NET 或 System.Text.Json 解析 JSON 请求体
- // 假设请求体中有一个名为 "dateTime" 的时间字段
- dynamic jsonData = JsonConvert.DeserializeObject(requestBody);
-
- if (jsonData.dateTime != null)
- {
- if (DateTime.TryParse((string)jsonData.dateTime, out DateTime dateTime))
- {
- // 将 JSON 请求体中的时间字段转换为服务器时区的时间
- var serverTime = TimeZoneInfo.ConvertTime(dateTime, timeZone);
- jsonData.dateTime = serverTime;
- }
- }
-
- // 将修改后的 JSON 请求体重新写入请求流中
- var jsonBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(jsonData));
- context.Request.Body = new MemoryStream(jsonBytes);
- context.Request.ContentLength = jsonBytes.Length;
- }
-
-
- // 处理 URL 表单参数
- var modifiedQuery = new Dictionary();
-
- foreach (var key in context.Request.Query.Keys)
- {
- if (DateTime.TryParse(context.Request.Query[key], out DateTime dateTime))
- {
- // 将 URL 表单参数中的时间转换为服务器时区的时间
- var serverTime = TimeZoneInfo.ConvertTime(dateTime, timeZone);
- modifiedQuery[key] = new StringValues(serverTime.ToString());
- }
- else
- {
- modifiedQuery[key] = context.Request.Query[key];
- }
- }
-
- context.Request.Query = new QueryCollection(modifiedQuery);
-
- // 处理Form请求体中的参数
- if (context.Request.HasFormContentType)
- {
- var modifiedForm = new Dictionary();
-
- foreach (var key in context.Request.Form.Keys)
- {
- if (DateTime.TryParse(context.Request.Form[key], out DateTime dateTime))
- {
- // 将请求体中的时间转换为服务器时区的时间
- var serverTime = TimeZoneInfo.ConvertTime(dateTime, timeZone);
- modifiedForm[key] = new StringValues(serverTime.ToString());
- }
- else
- {
- modifiedForm[key] = context.Request.Form[key];
- }
- }
-
- var newFormCollection = new FormCollection(modifiedForm);
-
- // 将新的表单集合设置回请求对象
- context.Request.Form = newFormCollection;
- }
-
- await _next(context);
- }
-
-}
diff --git a/IRaCIS.Core.API/Progranm.cs b/IRaCIS.Core.API/Progranm.cs
index 62e075ff6..5d258c077 100644
--- a/IRaCIS.Core.API/Progranm.cs
+++ b/IRaCIS.Core.API/Progranm.cs
@@ -111,7 +111,7 @@ builder.Services.AddControllers(options =>
options.Filters.Add();
options.Filters.Add();
options.Filters.Add();
- options.Filters.Add(10);
+ //options.Filters.Add(10);
options.Filters.Add();
@@ -122,7 +122,7 @@ builder.Services.AddOptions().Configure(_configuration.Ge
builder.Services.AddOptions().Configure(_configuration.GetSection("BasicSystemConfig"));
builder.Services.AddOptions().Configure(_configuration.GetSection("AliyunOSS"));
builder.Services.AddOptions().Configure(_configuration.GetSection("ObjectStoreService"));
-builder.Services.AddOptions().Configure(_configuration.GetSection("EncrypteResponseConfig"));
+builder.Services.AddOptions().Configure(_configuration.GetSection("EncrypteResponseConfig"));
builder.Services.AddOptions().Configure(_configuration.GetSection("SystemPacsConfig"));
builder.Services.Configure(_configuration.GetSection("IRaCISBasicConfig"));
@@ -218,6 +218,7 @@ var env = app.Environment;
#region 配置中间件
+app.UseMiddleware();
// Configure the HTTP request pipeline.
diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs
index a6e0352d5..176ea178c 100644
--- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs
+++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs
@@ -8,9 +8,11 @@ using Medallion.Threading;
using Medallion.Threading.SqlServer;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
+using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
using StackExchange.Redis;
namespace IRaCIS.Core.API
@@ -46,10 +48,11 @@ namespace IRaCIS.Core.API
else
{
options.UseSqlServer(configuration.GetSection("ConnectionStrings:RemoteNew").Value, contextOptionsBuilder => contextOptionsBuilder.EnableRetryOnFailure());
-
}
+ //迁移的时候,不生成外键
+ options.ReplaceService();
options.UseLoggerFactory(logFactory);
diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs
index ce758306c..0fada0af4 100644
--- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs
+++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs
@@ -35,7 +35,9 @@ namespace IRaCIS.Core.API
else
{
// Default or English date format
- _dateFormat = "MM/dd/yyyy HH:mm:ss";
+ //_dateFormat = "MM/dd/yyyy HH:mm:ss";
+
+ _dateFormat = "yyyy-MM-dd HH:mm:ss";
}
#endregion
diff --git a/IRaCIS.Core.API/appsettings.Event_IRC.json b/IRaCIS.Core.API/appsettings.Event_IRC.json
index fa5674cb6..e1994bdde 100644
--- a/IRaCIS.Core.API/appsettings.Event_IRC.json
+++ b/IRaCIS.Core.API/appsettings.Event_IRC.json
@@ -13,15 +13,16 @@
"ObjectStoreService": {
"ObjectStoreUse": "AliyunOSS",
"AliyunOSS": {
- "regionId": "cn-shanghai",
- "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
- "endpoint": "https://oss-cn-shanghai.aliyuncs.com",
- "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ",
- "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio",
- "bucketName": "zy-irc-store",
- "roleArn": "acs:ram::1899121822495495:role/oss-upload",
- "viewEndpoint": "https://zy-irc-cache.oss-cn-shanghai.aliyuncs.com",
- "region": "oss-cn-shanghai"
+ "RegionId": "cn-shanghai",
+ "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
+ "EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
+ "AccessKeyId": "LTAI5tNRTsqL6aWmHkDmTwoH",
+ "AccessKeySecret": "7mtGz3qrYWI6JMMBZiLeC119VWicZH",
+ "RoleArn": "acs:ram::1899121822495495:role/irc-oss-access",
+ "BucketName": "zy-irc-store",
+ "ViewEndpoint": "https://zy-irc-cache.oss-cn-shanghai.aliyuncs.com",
+ "Region": "oss-cn-shanghai",
+ "DurationSeconds": 7200
},
"MinIO": {
"endpoint": "http://192.168.3.68",
diff --git a/IRaCIS.Core.API/appsettings.Prod_IRC.json b/IRaCIS.Core.API/appsettings.Prod_IRC.json
index 293d9933e..4d24a5408 100644
--- a/IRaCIS.Core.API/appsettings.Prod_IRC.json
+++ b/IRaCIS.Core.API/appsettings.Prod_IRC.json
@@ -15,15 +15,16 @@
"ObjectStoreService": {
"ObjectStoreUse": "AliyunOSS",
"AliyunOSS": {
- "regionId": "cn-shanghai",
- "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
- "endpoint": "https://oss-cn-shanghai.aliyuncs.com",
- "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ",
- "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio",
- "bucketName": "zy-irc-store",
- "roleArn": "acs:ram::1899121822495495:role/oss-upload",
- "viewEndpoint": "https://zy-irc-cache.oss-cn-shanghai.aliyuncs.com",
- "region": "oss-cn-shanghai"
+ "RegionId": "cn-shanghai",
+ "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
+ "EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
+ "AccessKeyId": "LTAI5tNRTsqL6aWmHkDmTwoH",
+ "AccessKeySecret": "7mtGz3qrYWI6JMMBZiLeC119VWicZH",
+ "RoleArn": "acs:ram::1899121822495495:role/irc-oss-access",
+ "BucketName": "zy-irc-store",
+ "ViewEndpoint": "https://zy-irc-cache.oss-cn-shanghai.aliyuncs.com",
+ "Region": "oss-cn-shanghai",
+ "DurationSeconds": 7200
},
"MinIO": {
"endpoint": "http://192.168.3.68",
diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json
index 078086d1d..1ccc9c7f2 100644
--- a/IRaCIS.Core.API/appsettings.Test_IRC.json
+++ b/IRaCIS.Core.API/appsettings.Test_IRC.json
@@ -19,10 +19,10 @@
"RegionId": "cn-shanghai",
"InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
"EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
- "AccessKeyId": "LTAI5tJV76pYX5yPg1N9QVE8",
- "AccessKeySecret": "roRNLa9YG1of4pYruJGCNKBXEWTAWa",
+ "AccessKeyId": "LTAI5tRRZehUp2V9pyTPtAJm",
+ "AccessKeySecret": "FLizxkHsMm4CGYHtkV8E3PNJJZU7oV",
+ "RoleArn": "acs:ram::1899121822495495:role/dev-oss-access",
"BucketName": "zy-irc-test-store",
- "RoleArn": "acs:ram::1899121822495495:role/webdirect",
"ViewEndpoint": "https://zy-irc-test-store.oss-cn-shanghai.aliyuncs.com",
"Region": "oss-cn-shanghai",
"DurationSeconds": 7200
@@ -40,11 +40,11 @@
"Region": "us-east-1",
"EndPoint": "s3.us-east-1.amazonaws.com",
"UseSSL": true,
- "RoleArn": "arn:aws:iam::471112624751:role/sts_s3_upload",
- "AccessKeyId": "AKIAW3MEAFJXWRCGSX5Z",
- "SecretAccessKey": "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",
+ "RoleArn": "arn:aws:iam::471112624751:role/uat_s3_access",
+ "AccessKeyId": "AKIAW3MEAFJX7IPXISP4",
+ "SecretAccessKey": "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",
"BucketName": "ei-med-s3-lili-uat-store",
- "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/",
+ "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com",
"DurationSeconds": 7200
}
},
diff --git a/IRaCIS.Core.API/appsettings.US_Prod_IRC.json b/IRaCIS.Core.API/appsettings.US_Prod_IRC.json
index a27844759..2943de824 100644
--- a/IRaCIS.Core.API/appsettings.US_Prod_IRC.json
+++ b/IRaCIS.Core.API/appsettings.US_Prod_IRC.json
@@ -15,18 +15,6 @@
"ObjectStoreService": {
"ObjectStoreUse": "AWS",
- "AliyunOSS": {
- "regionId": "cn-shanghai",
- "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
- "endPoint": "https://oss-cn-shanghai.aliyuncs.com",
- "accessKeyId": "",
- "accessKeySecret": "",
- "bucketName": "zy-irc-test-store",
- "roleArn": "acs:ram::1899121822495495:role/oss-upload",
- "viewEndpoint": "https://zy-irc-test-store.oss-cn-shanghai.aliyuncs.com",
- "region": "oss-cn-shanghai"
- },
-
"MinIO": {
"endPoint": "44.210.231.169",
"port": "9001",
@@ -38,12 +26,15 @@
},
"AWS": {
- "endPoint": "s3.us-east-1.amazonaws.com",
- "useSSL": true,
- "accessKey": "AKIAW3MEAFJX5P32P6NA",
- "secretKey": "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",
- "bucketName": "ei-med-s3-lili-store",
- "viewEndpoint": "https://ei-med-s3-lili-store.s3.amazonaws.com/"
+ "Region": "us-east-1",
+ "EndPoint": "s3.us-east-1.amazonaws.com",
+ "UseSSL": true,
+ "RoleArn": "arn:aws:iam::471112624751:role/lili_s3_access",
+ "AccessKeyId": "AKIAW3MEAFJXZ2TZK7GM",
+ "SecretAccessKey": "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",
+ "BucketName": "ei-med-s3-lili-uat-store",
+ "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com",
+ "DurationSeconds": 7200
}
},
"BasicSystemConfig": {
@@ -86,7 +77,7 @@
},
"SystemPacsConfig": {
- "Port": "11113",
+ "Port": "104",
"IP": "44.210.231.169"
}
diff --git a/IRaCIS.Core.API/appsettings.US_Test_IRC.json b/IRaCIS.Core.API/appsettings.US_Test_IRC.json
index b45479ed8..e12bcd647 100644
--- a/IRaCIS.Core.API/appsettings.US_Test_IRC.json
+++ b/IRaCIS.Core.API/appsettings.US_Test_IRC.json
@@ -13,19 +13,7 @@
"ObjectStoreService": {
- "ObjectStoreUse": "MinIO",
- "AliyunOSS": {
- "regionId": "cn-shanghai",
- "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
- "endPoint": "https://oss-cn-shanghai.aliyuncs.com",
- "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ",
- "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio",
- "bucketName": "zy-irc-test-store",
- "roleArn": "acs:ram::1899121822495495:role/oss-upload",
- "viewEndpoint": "https://zy-irc-test-store.oss-cn-shanghai.aliyuncs.com",
- "region": "oss-cn-shanghai"
- },
-
+ "ObjectStoreUse": "AWS",
"MinIO": {
//"endPoint": "hir-oss.uat.extimaging.com",
//"port": "443",
@@ -44,23 +32,26 @@
},
"AWS": {
- "endPoint": "s3.us-east-1.amazonaws.com",
- "useSSL": true,
- "accessKey": "AKIAZQ3DRSOHFPJJ6FEU",
- "secretKey": "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",
- "bucketName": "ei-irc-test-store",
- "viewEndpoint": "https://ei-irc-test-store.s3.amazonaws.com/"
+ "Region": "us-east-1",
+ "EndPoint": "s3.us-east-1.amazonaws.com",
+ "UseSSL": true,
+ "RoleArn": "arn:aws:iam::471112624751:role/uat_s3_access",
+ "AccessKeyId": "AKIAW3MEAFJX7IPXISP4",
+ "SecretAccessKey": "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",
+ "BucketName": "ei-med-s3-lili-uat-store",
+ "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com",
+ "DurationSeconds": 7200
}
},
"BasicSystemConfig": {
- "OpenUserComplexPassword": false,
+ "OpenUserComplexPassword": true,
- "OpenSignDocumentBeforeWork": false,
+ "OpenSignDocumentBeforeWork": true,
"OpenTrialRelationDelete": true,
- "OpenLoginLimit": false,
+ "OpenLoginLimit": true,
"LoginMaxFailCount": 5,
@@ -72,7 +63,9 @@
"ReadingRestTimeMin": 10,
"IsNeedChangePassWord": true,
- "ChangePassWordDays": 90
+ "ChangePassWordDays": 90,
+
+ "OpenLoginMFA": true
},
"SystemEmailSendConfig": {
@@ -92,8 +85,8 @@
},
"SystemPacsConfig": {
- "Port": "11113",
- "IP": "3.226.182.187,1435"
+ "Port": "104",
+ "IP": "3.226.182.187"
}
}
diff --git a/IRaCIS.Core.API/appsettings.US_Uat_IRC.json b/IRaCIS.Core.API/appsettings.US_Uat_IRC.json
index faf47a861..b978dffcd 100644
--- a/IRaCIS.Core.API/appsettings.US_Uat_IRC.json
+++ b/IRaCIS.Core.API/appsettings.US_Uat_IRC.json
@@ -7,11 +7,11 @@
}
},
"ConnectionStrings": {
- "RemoteNew": "Server=us-mssql-service,1433;Database=US_Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
- "Hangfire": "Server=us-mssql-service,1433;Database=US_Uat_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
+ //"RemoteNew": "Server=us-mssql-service,1433;Database=US_Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
+ //"Hangfire": "Server=us-mssql-service,1433;Database=US_Uat_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
- //"RemoteNew": "Server=3.226.182.187,1435;Database=US_Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
- //"Hangfire": "Server=3.226.182.187,1435;Database=US_Uat_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
+ "RemoteNew": "Server=3.226.182.187,1435;Database=US_Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
+ "Hangfire": "Server=3.226.182.187,1435;Database=US_Uat_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
},
"ObjectStoreService": {
@@ -36,19 +36,22 @@
},
"AWS": {
- "endPoint": "s3.us-east-1.amazonaws.com",
- "useSSL": true,
- "accessKey": "AKIAW3MEAFJXUO6XYFYN",
- "secretKey": "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",
- "bucketName": "ei-med-s3-lili-uat-store",
- "viewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/"
+ "Region": "us-east-1",
+ "EndPoint": "s3.us-east-1.amazonaws.com",
+ "UseSSL": true,
+ "RoleArn": "arn:aws:iam::471112624751:role/uat_s3_access",
+ "AccessKeyId": "AKIAW3MEAFJX7IPXISP4",
+ "SecretAccessKey": "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",
+ "BucketName": "ei-med-s3-lili-uat-store",
+ "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/",
+ "DurationSeconds": 7200
}
},
"BasicSystemConfig": {
- "OpenUserComplexPassword": false,
+ "OpenUserComplexPassword": true,
- "OpenSignDocumentBeforeWork": false,
+ "OpenSignDocumentBeforeWork": true,
"OpenTrialRelationDelete": true,
@@ -66,7 +69,7 @@
"ChangePassWordDays": 90,
- "OpenLoginMFA": true
+ "OpenLoginMFA": false
},
"SystemEmailSendConfig": {
@@ -86,8 +89,8 @@
},
"SystemPacsConfig": {
- "Port": "11113",
- "IP": "3.226.182.187,1435"
+ "Port": "104",
+ "IP": "3.226.182.187"
}
}
diff --git a/IRaCIS.Core.API/appsettings.Uat_IRC.json b/IRaCIS.Core.API/appsettings.Uat_IRC.json
index 1493f5f84..087236feb 100644
--- a/IRaCIS.Core.API/appsettings.Uat_IRC.json
+++ b/IRaCIS.Core.API/appsettings.Uat_IRC.json
@@ -18,10 +18,10 @@
"RegionId": "cn-shanghai",
"InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
"EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
- "AccessKeyId": "LTAI5tJV76pYX5yPg1N9QVE8",
- "AccessKeySecret": "roRNLa9YG1of4pYruJGCNKBXEWTAWa",
+ "AccessKeyId": "LTAI5tRRZehUp2V9pyTPtAJm",
+ "AccessKeySecret": "FLizxkHsMm4CGYHtkV8E3PNJJZU7oV",
+ "RoleArn": "acs:ram::1899121822495495:role/dev-oss-access",
"BucketName": "zy-irc-uat-store",
- "RoleArn": "acs:ram::1899121822495495:role/webdirect",
"ViewEndpoint": "https://zy-irc-uat-store.oss-cn-shanghai.aliyuncs.com",
"Region": "oss-cn-shanghai",
"DurationSeconds": 7200
diff --git a/IRaCIS.Core.API/appsettings.json b/IRaCIS.Core.API/appsettings.json
index 75bc653af..529451e7f 100644
--- a/IRaCIS.Core.API/appsettings.json
+++ b/IRaCIS.Core.API/appsettings.json
@@ -43,40 +43,6 @@
}
]
},
- "easycaching": {
- "inmemory": {
- "MaxRdSecond": 120,
- "EnableLogging": false,
- "LockMs": 5000,
- "SleepMs": 300,
- "DBConfig": {
- "SizeLimit": 10000,
- "ExpirationScanFrequency": 60,
- "EnableReadDeepClone": true,
- "EnableWriteDeepClone": false
- }
- },
- "redis": {
- "MaxRdSecond": 120,
- "EnableLogging": false,
- "LockMs": 5000,
- "SleepMs": 300,
- "dbconfig": {
- "Password": "xc@123456",
- "IsSsl": false,
- "SslHost": null,
- "ConnectionTimeout": 5000,
- "AllowAdmin": true,
- "Endpoints": [
- {
- "Host": "47.117.164.182",
- "Port": 6379
- }
- ],
- "Database": 0
- }
- }
- },
"IRaCISImageStore": {
"SwitchingMode": "RemainingDiskCapacity",
"SwitchingRatio": 80,
@@ -93,9 +59,10 @@
"DefaultPassword": "123456",
"ImageShareExpireDays": 10
},
-
"EncrypteResponseConfig": {
- "IsEnable": true,
+ "Base64RSAPublicKey": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0NCk1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBaHp3T1hYTWYyaEFkS1ZoWHczYUYNCmNaT3QycE1lcmdEaFVrOUdQK2s4VDBrUjFTRVlGVGtzNlkzaEVvL0dRTExqMHZFYVV3bTNhSFNuTTl5NmdLRWoNCmY5cTN6dkoyZzRSQjE4Z0UrTnNWWi9DMkVRZ3k5OWFiWGc5TitGREVlT0NmSjlSRTJPV3JBQ2s0V0RPbFFUdXYNCnhvR2JmcnkwVElSaFBrOGtuYkFmVkZ1and1VXJGblpJZ0ExYXhKZVZ6aDhwcmV1SEgreW1jdHp6NVo4V1pSV3kNCi9ISURHUy90dkg2NUMra2l6cUxRYUpKNHYwODMrRGpaVTBmNzNCdkk5eWt1dW1saXFzY1pvU2preDFOUFJwSkUNCkFtMVFNQ0hMRCtFdzlHT2Vsc2Mwa1ZxdjdaeEF1TkFrMkZuUURNRk1BUmZuUFd0aGVhOGZYVTJsMW9ROWs3WDcNCmN3SURBUUFCDQotLS0tLUVORCBQVUJMSUMgS0VZLS0tLS0NCg==",
+ "Base64RSAPrivateKey": "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQ0KTUlJRW9nSUJBQUtDQVFFQWh6d09YWE1mMmhBZEtWaFh3M2FGY1pPdDJwTWVyZ0RoVWs5R1ArazhUMGtSMVNFWQ0KRlRrczZZM2hFby9HUUxMajB2RWFVd20zYUhTbk05eTZnS0VqZjlxM3p2SjJnNFJCMThnRStOc1ZaL0MyRVFneQ0KOTlhYlhnOU4rRkRFZU9DZko5UkUyT1dyQUNrNFdET2xRVHV2eG9HYmZyeTBUSVJoUGs4a25iQWZWRnVqd3VVcg0KRm5aSWdBMWF4SmVWemg4cHJldUhIK3ltY3R6ejVaOFdaUld5L0hJREdTL3R2SDY1QytraXpxTFFhSko0djA4Mw0KK0RqWlUwZjczQnZJOXlrdXVtbGlxc2Nab1Nqa3gxTlBScEpFQW0xUU1DSExEK0V3OUdPZWxzYzBrVnF2N1p4QQ0KdU5BazJGblFETUZNQVJmblBXdGhlYThmWFUybDFvUTlrN1g3Y3dJREFRQUJBb0lCQUNDRFoxNi9XWWFYZmpOZA0KQ29pemU2VFJZU2llVzI5eFJic0ExVDV6YUcwVmY4U1NsdFF2Y1dWYmw2UGJUa3BxMkF4MHJDUVB2M2xOSm8vNA0KL3h3QzRlS1E1c1ZLRlFWTXJIbmhISlRxTTJ6UWVpMkJINlBuaEdZcVh0QVhOdzFxejhrSEoyQlFZM3IvN2d5Qw0KcWpZVFVCRDFRem5HeThCanlXOXVIcnNNeDVPRHRRZWxBM3B1TFd1bXZNb3Z1L2JhaDZvTGtOSHY4b0VTdzhGSQ0KTllyTUtscHhFTjZaWUdwSTl2VTZnYUhuTmhEa2ExTHlvUnZ5NnA2dTRLR0FsRTc1VXk4T0dsdncydU5uay9sdg0KSEMyYnY5TnlCRGJpSFNDY0MyK1JXUXMrN0tNWFlwYnBvTVFCR0hqV01GRHVBODFaUCs1TWYxUm9yQUpRNGxrRw0KQnRDQThva0NnWUVBeWY4alBjcFIvQ3dJNU5MYnlwb3ZUWEFHVkFKMmtWRlJVUC9HT2ZOMkFyYWMvL20wdDJ5NA0KemNYVkJZc0pJeHkvVWYxRTFJNFg3VFg3V3NBNGxVNGlPTkwzTnN4dDBEbk1PV2tKUlBPZlF1bW1JaWw5QVRiYQ0KTnRVWFNlTmRoUFFGMGlCb21acFFJYWpSN1RmUnVBbzR6dmpTLzkzeXZZY0lIWU1zM0tjR00ya0NnWUVBcTJPbg0KZlp0RmhLTElGanVlRzRrNklGTWdjbytEUUh5TTFWSUp5Tk05K1o2TEgybzI5eDJCaSs2Qm82M2NKUjQ2STZncQ0KNWUrSTBvdzZRYmNQeTZUNHFSQ0o3Ujd6MllkdEw4eXdJTkNYS3U0cC9qaFNqNWJ1TzFJWlI3ZStSV29CakNtUQ0KWFd0ZVBCbldqWVlLdVRCazROc2FXV09GTXg1QndKdUp2MjBnQ0hzQ2dZQlV4QnFYM1lWV0cyeUlDZXh1TXhIUw0KbjBZb2p2Z090MTgyYkg5VTVsUUpnM1NTL3NqVmlHeHMvYTROSzNGa0tMWW93KzNVZk9TUmlPdTRBNTQ3R1pURw0KMzlFYVQrTnRWRFBkaTdSMkdQNG1hRUp0WjVlcm9NY2w1M3BrYVdOZlhiL3JrK29STzI2UkVYVTI1UXUrL1pzbA0KVDhuTDBlb0JtdDdPODdNcHpYV09zUUtCZ0ZxVGFQSGx2RUNUY3FEbFV2S0VmRmFXOTkvelhrOFhRNnA5RjdTdA0KaHVSRDJJeDZxcC9BVlRWcGo5Tzd6MHRDaFVGUTM1THpHMkVDUU10My9uNEdLbS9XMEwyakRRWWFIeWNTeXNZYw0KMXJjV2ROVG9XU0dQaDBtTVl0WFhFbFJHNkpoMVl0a3NJL29wUVkwN21MRTBGU3dNUHdtY29jbFpKVEN3UW9VTA0KRzlHL0FvR0FWM25kcWcydnUyR0x4TlRUbm1UTWRJNFB3UzBmN0V4VnVNUnRicGZyOWhKNzlDakVNTGFXQ1FsNg0KeE43TElMTnArNVQwQW1DZVBqcitkbnJkRUNidFZPTDFybDc3Z0krRkwzaVVqYmZmMVZqa0N3M0x6K3cyb1FFdA0KbGE4aTZrL1NRK01iYkRPaWRJOVczdlN6MmlJRlZobWJiK1Q2SlZwakxqNjlkblM3eUxZPQ0KLS0tLS1FTkQgUlNBIFBSSVZBVEUgS0VZLS0tLS0NCg==",
+ "IsResponseEncreptEnable": true,
"ApiPathList": [
"/test/get"
]
diff --git a/IRaCIS.Core.Application/BusinessFilter/EncreptApiResultFilter.cs b/IRaCIS.Core.Application/BusinessFilter/EncreptApiResultFilter.cs
deleted file mode 100644
index fd58ae885..000000000
--- a/IRaCIS.Core.Application/BusinessFilter/EncreptApiResultFilter.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using IRaCIS.Core.Domain.Share;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Filters;
-using Microsoft.Extensions.Options;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace IRaCIS.Core.Application.BusinessFilter
-{
- public class EncreptApiResultFilter : IAsyncResultFilter
- {
-
- private readonly IOptionsMonitor _encreptResponseMonitor;
-
- public EncreptApiResultFilter(IOptionsMonitor encreptResponseMonitor)
- {
- _encreptResponseMonitor = encreptResponseMonitor;
- }
-
- public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
- {
-
- if(_encreptResponseMonitor.CurrentValue.IsEnable)
- {
-
- if (context.Result is ObjectResult objectResult)
- {
- var statusCode = objectResult.StatusCode ?? context.HttpContext.Response.StatusCode;
-
- var objectValue = objectResult.Value;
-
-
- if (objectValue is IResponseOutput)
- {
- var responseOutput = objectValue as IResponseOutput
+
+
+ 测试加密API 返回的结果
+
+
+
+
+ https://www.cnblogs.com/NBDWDYS2214143926/p/13329231.html
+
+
+
+
+ RSA解密
+
+ 私钥
+ 待解密的字符串(Base64)
+ 解密后的字符串
+
+
不生效,不知道为啥
@@ -102,20 +121,6 @@
-
-
- https://www.cnblogs.com/NBDWDYS2214143926/p/13329231.html
-
-
-
-
- RSA解密
-
- 私钥
- 待解密的字符串(Base64)
- 解密后的字符串
-
-
利用DocX 库 处理word国际化模板
@@ -902,7 +907,7 @@
TrialEmailNoticeConfigService
-
+
TrialEmailNoticeConfigService
@@ -1371,7 +1376,7 @@
-
+
获取查询对象
@@ -1384,7 +1389,7 @@
-
+
复制配置项及其子项
@@ -1398,14 +1403,14 @@
数据集
-
+
翻译稽查数据
-
+
翻译稽查数据
@@ -10812,9 +10817,6 @@
业务层级 ///
-
- 邮件类型 ///
-
邮件加急类型 ///
@@ -10839,6 +10841,21 @@
SystemAnonymizationAddOrEdit 列表查询参数模型
+
+
+ 质疑
+
+
+
+
+ 一致性核查
+
+
+
+
+ 复制
+
+
SystemNoticeView 列表视图模型
@@ -11774,9 +11791,6 @@
业务层级 ///
-
- 邮件类型 ///
-
邮件加急类型 ///
@@ -11847,7 +11861,7 @@
NoneDicomStudyService
-
+
NoneDicomStudyService
diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs
index 89d943028..226e8ac94 100644
--- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs
@@ -27,13 +27,13 @@ namespace IRaCIS.Core.Application.Service
{
-
+
///
/// 获取计划列表 医生带阅片类型
///
///
///
- public async Task<(List,object)> GetDoctorPlanAllocationRuleList(Guid trialId)
+ public async Task>> GetDoctorPlanAllocationRuleList(Guid trialId)
{
var list = await _taskAllocationRuleRepository.Where(t => t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
@@ -41,7 +41,7 @@ namespace IRaCIS.Core.Application.Service
//所有标准都是一样 后台只返回任意一个标准的就好了
var trialTaskConfig = await _readingQuestionCriterionTrialRepository.Where(t => t.TrialId == trialId && t.IsConfirm).ProjectTo(_mapper.ConfigurationProvider).FirstNotNullAsync();
- return (list, trialTaskConfig);
+ return ResponseOutput.Ok(list, trialTaskConfig);
}
@@ -103,9 +103,9 @@ namespace IRaCIS.Core.Application.Service
// return ResponseOutput.Ok();
//}
- public async Task> GetSubjectCancelDoctorHistoryList(Guid subjectId,Guid trialReadingCriterionId)
+ public async Task> GetSubjectCancelDoctorHistoryList(Guid subjectId, Guid trialReadingCriterionId)
{
- var list = await _subjectCanceDoctorRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId==trialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
+ var list = await _subjectCanceDoctorRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
return list;
}
@@ -139,7 +139,7 @@ namespace IRaCIS.Core.Application.Service
};
- return await query.ToListAsync();
+ return await query.ToListAsync();
}
@@ -150,8 +150,8 @@ namespace IRaCIS.Core.Application.Service
var query = from allocationRule in _taskAllocationRuleRepository.Where(t => t.TrialId == selectQuery.TrialId && t.IsEnable)
.WhereIf(selectQuery.ReadingCategory != null && selectQuery.TrialReadingCriterionId == null, t => t.Enroll.EnrollReadingCategoryList.Any(t => t.ReadingCategory == selectQuery.ReadingCategory))
.WhereIf(selectQuery.TrialReadingCriterionId != null && selectQuery.ReadingCategory == null, t => t.Enroll.EnrollReadingCategoryList.Any(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId))
- .WhereIf(selectQuery.TrialReadingCriterionId != null && selectQuery.ReadingCategory !=null,
- t => t.Enroll.EnrollReadingCategoryList.Any(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId && t.ReadingCategory==selectQuery.ReadingCategory))
+ .WhereIf(selectQuery.TrialReadingCriterionId != null && selectQuery.ReadingCategory != null,
+ t => t.Enroll.EnrollReadingCategoryList.Any(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId && t.ReadingCategory == selectQuery.ReadingCategory))
join user in _userRepository.AsQueryable() on allocationRule.DoctorUserId equals user.Id
select new TrialDoctorUserSelectView()
{
@@ -162,12 +162,12 @@ namespace IRaCIS.Core.Application.Service
UserName = user.UserName,
UserTypeEnum = user.UserTypeRole.UserTypeEnum,
- ReadingCategoryList = selectQuery.TrialReadingCriterionId == null ?
-
- allocationRule.Enroll.EnrollReadingCategoryList.Where(t=> (selectQuery.ReadingCategory == null ?true: t.ReadingCategory == selectQuery.ReadingCategory) ).Select(t => t.ReadingCategory).OrderBy(t => t).ToList() :
-
+ ReadingCategoryList = selectQuery.TrialReadingCriterionId == null ?
+
+ allocationRule.Enroll.EnrollReadingCategoryList.Where(t => (selectQuery.ReadingCategory == null ? true : t.ReadingCategory == selectQuery.ReadingCategory)).Select(t => t.ReadingCategory).OrderBy(t => t).ToList() :
+
allocationRule.Enroll.EnrollReadingCategoryList
- .Where(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId && (selectQuery.ReadingCategory == null?true : t.ReadingCategory == selectQuery.ReadingCategory) )
+ .Where(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId && (selectQuery.ReadingCategory == null ? true : t.ReadingCategory == selectQuery.ReadingCategory))
.Select(t => t.ReadingCategory).OrderBy(t => t).ToList()
};
diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
index db1f15367..23fdf23b1 100644
--- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
@@ -96,7 +96,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.EndSignTime != null, t => t.SignTime <= inQuery.EndSignTime)
.ProjectTo(_mapper.ConfigurationProvider);
- var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTask.VisitTaskNum) };
+ var defalutSortArray = new string[] { nameof(AnalysisTaskView.IsUrgent) + " desc", nameof(AnalysisTaskView.SubjectCode), nameof(AnalysisTaskView.VisitTaskNum) };
var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
#region 统计一致性分析临床数据数量
diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs
index 6d352635f..393edc9a0 100644
--- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs
@@ -66,7 +66,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.EndAuditSignTime != null, t => t.AuditSignTime <= inQuery.EndAuditSignTime)
.ProjectTo(_mapper.ConfigurationProvider);
- var defalutSortArray = new string[] { nameof(TaskMedicalReviewView.AuditState), nameof(TaskMedicalReviewView.SubjectId), nameof(TaskMedicalReviewView.ArmEnum) , nameof(TaskMedicalReviewView.VisitTaskNum) };
+ var defalutSortArray = new string[] { nameof(TaskMedicalReviewView.AuditState), nameof(TaskMedicalReviewView.SubjectCode), nameof(TaskMedicalReviewView.ArmEnum) , nameof(TaskMedicalReviewView.VisitTaskNum) };
var pageList = await taskMedicalReviewQueryable.ToPagedListAsync(inQuery, defalutSortArray);
return pageList;
@@ -102,7 +102,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.EndSignTime != null, t => t.SignTime < inQuery.EndSignTime)
.ProjectTo(_mapper.ConfigurationProvider);
- var defalutSortArray = new string[] { nameof(GenerateMedicalReviewTaskView.IsUrgent) + " desc", nameof(GenerateMedicalReviewTaskView.SubjectId) };
+ var defalutSortArray = new string[] { nameof(GenerateMedicalReviewTaskView.IsUrgent) + " desc", nameof(GenerateMedicalReviewTaskView.SubjectCode) };
var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
@@ -239,7 +239,7 @@ namespace IRaCIS.Core.Application.Service
.ProjectTo(_mapper.ConfigurationProvider);
- var defalutSortArray = new string[] { nameof(TaskMedicalReviewView.SubjectId), nameof(TaskMedicalReviewView.ArmEnum), nameof(TaskMedicalReviewView.VisitTaskNum) };
+ var defalutSortArray = new string[] { nameof(TaskMedicalReviewView.SubjectCode), nameof(TaskMedicalReviewView.ArmEnum), nameof(TaskMedicalReviewView.VisitTaskNum) };
var pageList = await taskMedicalReviewQueryable.ToPagedListAsync(inQuery, defalutSortArray);
return ResponseOutput.Ok(pageList, new
diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs
index 55193572a..d8345c225 100644
--- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs
@@ -24,2667 +24,1812 @@ using MassTransit;
using System.Reactive.Subjects;
using Subject = IRaCIS.Core.Domain.Models.Subject;
-namespace IRaCIS.Core.Application.Service.Allocation
+namespace IRaCIS.Core.Application.Service.Allocation;
+
+///
+/// 访视读片任务
+///
+[ApiExplorerSettings(GroupName = "Trial")]
+public class VisitTaskService(IRepository _visitTaskRepository,
+ IRepository _trialRepository,
+ IRepository _subjectVisitRepository,
+ IRepository _taskAllocationRuleRepository,
+ IRepository _subjectRepository,
+ IRepository _subjectUserRepository,
+ IRepository _readModuleRepository,
+ IRepository _visitTaskReReadingRepository,
+ IRepository _taskMedicalReviewRepository,
+ IRepository _readingClinicalDataReposiotry,
+ IRepository _subjectCriteriaEvaluationRepository,
+ IRepository _subjectCriteriaEvaluationVisitFilterRepository,
+ IRepository _trialReadingCriterionRepository,
+ IRepository _readingQuestionCriterionTrialRepository,
+ IRepository _readingTaskQuestionAnswerRepository,
+ IRepository _dicomInstanceRepository,
+ IRepository _dicomSeriesRepository,
+ IRepository _subjectCanceDoctorRepository,
+ IRepository _readingTaskQuestionMarkRepository,
+ IRepository _readingTableAnswerRowInfoRepository,
+ IRepository _readingCustomTagRepository,
+ IRepository _taskInfluenceRepository,
+ IRepository _trialQCQuestionAnswerRepository,
+ IRepository _subjectCriteriaEvaluationVisitStudyFilterRepository) : BaseService, IVisitTaskService
{
+
+
+
///
- /// 访视读片任务
- ///
- [ApiExplorerSettings(GroupName = "Trial")]
- public class VisitTaskService(IRepository _visitTaskRepository,
- IRepository _trialRepository,
- IRepository _subjectVisitRepository,
- IRepository _taskAllocationRuleRepository,
- IRepository _subjectRepository,
- IRepository _subjectUserRepository,
- IRepository _readModuleRepository,
- IRepository _visitTaskReReadingRepository,
- IRepository _taskMedicalReviewRepository,
- IRepository _readingClinicalDataReposiotry,
- IRepository _subjectCriteriaEvaluationRepository,
- IRepository _subjectCriteriaEvaluationVisitFilterRepository,
- IRepository _trialReadingCriterionRepository,
- IRepository _readingQuestionCriterionTrialRepository,
- IRepository _readingTaskQuestionAnswerRepository,
- IRepository _dicomInstanceRepository,
- IRepository _dicomSeriesRepository,
- IRepository _subjectCanceDoctorRepository,
- IRepository _readingTaskQuestionMarkRepository,
- IRepository _readingTableAnswerRowInfoRepository,
- IRepository _readingCustomTagRepository,
- IRepository _taskInfluenceRepository,
- IRepository _trialQCQuestionAnswerRepository,
- IRepository _subjectCriteriaEvaluationVisitStudyFilterRepository) : BaseService, IVisitTaskService
+ /// 设置任务加急
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task SetTaskUrgent(SetTaskUrgentInDto inDto)
+ {
+ await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
+ {
+ IsUrgent = inDto.IsUrgent,
+ TaskUrgentType = inDto.TaskUrgentType,
+ TaskUrgentRemake = inDto.TaskUrgentRemake,
+
+ });
+
+ return await _visitTaskRepository.SaveChangesAsync();
+ }
+
+ public async Task> GetTrialCriterionList(Guid trialId, bool isHaveSigned = true, bool? isAutoCreate = null)
+ {
+ var list = await _readingQuestionCriterionTrialRepository.Where(t => t.TrialId == trialId && t.IsConfirm)
+
+ .OrderBy(t => t.ShowOrder)
+ .Select(t => new TrialReadingCriterionDto()
+ {
+ TrialReadingCriterionId = t.Id,
+ IsAutoCreate = t.IsAutoCreate,
+ IsAdditionalAssessment = t.IsAdditionalAssessment,
+ TrialReadingCriterionName = t.CriterionName,
+ CriterionType = t.CriterionType,
+ ReadingType = t.ReadingType,
+ ReadingInfoSignTime = t.ReadingInfoSignTime,
+ IsReadingPeriod = t.IsReadingPeriod,
+ IsArbitrationReading = t.IsArbitrationReading,
+ IsGlobalReading = t.IsGlobalReading,
+ IsOncologyReading = t.IsOncologyReading,
+ ImageDownloadEnum = t.ImageDownloadEnum,
+ ImageUploadEnum = t.ImageUploadEnum,
+ IsReadingTaskViewInOrder = t.IsReadingTaskViewInOrder
+ })
+ .ToListAsync();
+
+ //if (list.Count == 0)
+ //{
+ // //---该项目还未确认任何一个阅片标准
+ // throw new BusinessValidationFailedException(_localizer["VisitTask_VisitTask_TaskAlreadyApplied"]);
+
+ //}
+
+
+ return list.AsQueryable().WhereIf(isHaveSigned == true, t => t.ReadingInfoSignTime != null)
+ .WhereIf(isAutoCreate == false, t => t.IsAutoCreate == isAutoCreate).ToList();
+ }
+
+
+
+
+ ///
+ /// Subject 任务类型 统计 +分配情况
+ ///
+ ///
+ [HttpPost]
+ public async Task>> GetSubjectAssignAndTaskStatList(SubjectAssignStatQuery inQuery)
+ {
+
+ var isAddtinoarlCriterion = await _trialReadingCriterionRepository.AnyAsync(t => t.Id == inQuery.TrialReadingCriterionId && t.IsAutoCreate == false);
+
+ var subjectQuery = _subjectRepository.Where(t => t.TrialId == inQuery.TrialId && t.SubjectVisitTaskList.Any())
+ .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.Id == inQuery.SubjectId)
+ .WhereIf(inQuery.DoctorUserId != null, t => t.SubjectDoctorList.Any(t => t.DoctorUserId == inQuery.DoctorUserId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.Code.Contains(inQuery.SubjectCode))
+ //未分配
+ .WhereIf(inQuery.SubjectAllocateState == 0, t => !t.SubjectDoctorList.Any(t => t.AssignTime != null && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId))
+ //已分配
+ .WhereIf(inQuery.SubjectAllocateState == 1, t => t.SubjectDoctorList.Any(t => t.AssignTime != null && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId))
+
+ .WhereIf(inQuery.ArmList.Count > 0, t => !inQuery.ArmList.Except(t.SubjectDoctorList.Where(t => t.AssignTime != null && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId).Select(c => c.ArmEnum)).Any())
+
+
+ .WhereIf(isAddtinoarlCriterion, t => t.SubjectCriteriaEvaluationList.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId).Any(t => t.IsJoinEvaluation))
+
+
+ .ProjectTo(_mapper.ConfigurationProvider, new { trialReadingCriterionId = inQuery.TrialReadingCriterionId });
+
+
+ var pageList = await subjectQuery.ToPagedListAsync(inQuery,nameof(SubjectAssignStat.SubjectId));
+
+
+
+ var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == inQuery.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsArbitrationReading, x.IsOncologyReading, x.IsGlobalReading }).FirstOrDefaultAsync()).IfNullThrowException();
+
+ return ResponseOutput.Ok(pageList, criterionConfig);
+ }
+
+ ///
+ /// 一次性分配所有医生 批量分配(添加),后端现在没限制
+ ///
+ ///
+ ///
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ public async Task BatchAssignDoctorToSubject(BatchAssignDoctorToSubjectCommand command)
+ {
+ //var inOrder = _trialRepository.Where(t => t.Id == command.TrialId).Select(t => t.IsReadingTaskViewInOrder).FirstOrDefault();
+
+ //var inOrder = _trialReadingCriterionRepository.Where(t => t.Id == command.TrialReadingCriterionId).Select(t => t.IsReadingTaskViewInOrder).FirstOrDefault();
+
+
+ foreach (var subjectId in command.SubjectIdList)
+ {
+ foreach (var doctorArm in command.DoctorArmList)
+ {
+ if (!await _subjectUserRepository.Where(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId).AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.ReplacedSubjectUserId == null))
+ {
+ await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = command.TrialId, TrialReadingCriterionId = command.TrialReadingCriterionId, ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now });
+
+ //task.SuggesteFinishedTime = task.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7);
+
+ }
+
+
+ Expression> updateWhere = t => t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false;
+
+ //if (inOrder)
+ //{
+ // //针对有序阅片 只分配< 最小的 不是一致性核查通过状态 和不是失访 的访视 的任务
+ // if (await _subjectVisitRepository.AnyAsync(t => t.SubjectId == subjectId && t.CheckState != CheckStateEnum.CVPassed && t.IsLostVisit == false))
+ // {
+ // var notCheckPassedMinVisitNum = await _subjectVisitRepository.Where(t => t.SubjectId == subjectId && t.CheckState != CheckStateEnum.CVPassed).OrderBy(t => t.VisitNum).Select(t => t.VisitNum).FirstOrDefaultAsync();
+
+ // updateWhere = updateWhere.And(t => t.VisitTaskNum < notCheckPassedMinVisitNum);
+
+ // }
+
+ //}
+
+
+ await _visitTaskRepository
+ .UpdatePartialFromQueryAsync(updateWhere,
+ u => new VisitTask()
+ {
+ AllocateTime = DateTime.Now,
+ DoctorUserId = doctorArm.DoctorUserId,
+ TaskAllocationState = TaskAllocationState.Allocated,
+
+ SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget),
+ });
+ }
+ }
+
+ await _subjectUserRepository.SaveChangesAsync();
+
+
+
+
+
+ return ResponseOutput.Ok();
+ }
+
+
+
+ ///
+ /// 阅片人维度 Subject统计表
+ ///
+ ///
+ ///
+ ///
+ public async Task<(List, object)> GetDoctorSubjectStat(Guid trialId, Guid trialReadingCriterionId)
+ {
+ var list = await _taskAllocationRuleRepository.Where(t => t.TrialId == trialId)
+ .Where(t => t.Enroll.EnrollReadingCategoryList.Any(t => t.TrialReadingCriterionId == trialReadingCriterionId))
+ .ProjectTo(_mapper.ConfigurationProvider, new { trialReadingCriterionId = trialReadingCriterionId }).ToListAsync();
+
+ var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsArbitrationReading, x.IsOncologyReading }).FirstOrDefaultAsync()).IfNullThrowException();
+
+ return (list, criterionConfig);
+ }
+
+
+ ///
+ /// 获取Subject 分配医生情况
+ ///
+ ///
+ ///
+ ///
+ public async Task<(List, object)> GetSubjectAssignedDoctorList(Guid subjectId, Guid trialReadingCriterionId)
+ {
+ var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed && t.TrialReadingCriterionId == trialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
+
+ var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsGlobalReading, x.IsOncologyReading, x.IsArbitrationReading }).FirstOrDefaultAsync()).IfNullThrowException();
+
+ return (list, criterionConfig);
+ }
+
+
+ ///
+ /// 取消Subject 分配的医生
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ public async Task CancelSubjectAssignedDoctor(CancelSubjectDoctorCommand cancelCommand)
+ {
+ foreach (var command in cancelCommand.CancelList.Where(t => t.IsCancelAssign))
+ {
+ if (await _visitTaskRepository.AnyAsync(t => t.TaskState == TaskState.Effect && t.TrialReadingCriterionId == cancelCommand.TrialReadingCriterionId && t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState != ReadingTaskState.WaitReading))
+ {
+ //---当前医生已开始做该Subject 该标准的任务,不允许取消分配
+ throw new BusinessValidationFailedException(_localizer["VisitTask_DoctorConfigNotFound"]);
+ }
+
+ await _subjectUserRepository.DeleteFromQueryAsync(t => t.Id == command.Id);
+
+ await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterionId == cancelCommand.TrialReadingCriterionId && t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false, u => new VisitTask()
+ {
+ AllocateTime = null,
+ DoctorUserId = null,
+ TaskAllocationState = TaskAllocationState.NotAllocate,
+ SuggesteFinishedTime = null
+ });
+ }
+
+ var subjectId = cancelCommand.CancelList.First().SubjectId;
+
+ await _subjectCanceDoctorRepository.AddAsync(new SubjectCanceDoctor() { SubjectId = subjectId, Note = cancelCommand.Note, TrialReadingCriterionId = cancelCommand.TrialReadingCriterionId });
+
+ await _visitTaskRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok();
+ }
+
+
+
+
+ ///
+ /// 任务 手动分配 重新分配 确认 取消分配
+ /// 分配
+ ///
+ ///
+ [HttpPost]
+ [UnitOfWork]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ public async Task AssignSubjectTaskToDoctor(AssignSubjectTaskToDoctorCommand assignSubjectTaskToDoctorCommand)
+ {
+ var visitTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == assignSubjectTaskToDoctorCommand.Id);
+
+ if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Assign || assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign)
+ {
+ //手动分配验证规则
+
+ if (visitTask.SourceSubjectVisitId != null)
+ {
+
+ if (await _visitTaskRepository.AnyAsync(t => t.SourceSubjectVisitId == visitTask.SourceSubjectVisitId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id))
+ {
+ //---其中一个任务已分配给该医生,不允许分配
+ return ResponseOutput.NotOk(_localizer["VisitTask_BackendDataError"]);
+ }
+ }
+ else if (visitTask.SouceReadModuleId != null)
+ {
+ if (await _visitTaskRepository.AnyAsync(t => t.SouceReadModuleId == visitTask.SouceReadModuleId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id))
+ {
+ //---其中一个任务已分配给该医生,不允许分配
+ return ResponseOutput.NotOk(_localizer["VisitTask_BackendDataError"]);
+ }
+ }
+ else
+ {
+ //---出现脏数据 任务来源字段没有值
+ throw new BusinessValidationFailedException(_localizer["VisitTask_DirtyData"]);
+ }
+
+ //PM 回退了 但是还没生成任务 当前任务编号前有访视进行了回退就不允许分配
+ if (await _subjectVisitRepository.AnyAsync(t => t.SubjectId == visitTask.SubjectId && t.IsPMBackOrReReading && t.VisitNum <= visitTask.VisitTaskNum))
+ {
+ //---该受试者有访视进入了退回流程,还未经过一致性核查通过,不允许分配
+ return ResponseOutput.NotOk(_localizer["VisitTask_MissingTaskSource"]);
+ }
+
+
+ visitTask.AllocateTime = DateTime.Now;
+ visitTask.DoctorUserId = assignSubjectTaskToDoctorCommand.DoctorUserId;
+ visitTask.TaskAllocationState = TaskAllocationState.Allocated;
+
+ visitTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget);
+
+
+
+ //await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading });
+
+ //await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading });
+ }
+
+ else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign)
+ {
+ //验证 是不是两个任务都给了同一个医生
+
+
+
+ //是否删除配置规则表里的 Subject 医生绑定关系 重新添加绑定关系
+
+ //是否其该Subject 其他访视 绑定的医生 也同时变更?
+
+
+ }
+
+ else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Confirm)
+ {
+ visitTask.TaskAllocationState = TaskAllocationState.Allocated;
+ }
+ else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.CancelAssign)
+ {
+ visitTask.AllocateTime = null;
+ visitTask.DoctorUserId = null;
+ visitTask.TaskAllocationState = TaskAllocationState.NotAllocate;
+
+ //await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.TaskAllocate });
+
+ //await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.TaskAllocate });
+ }
+ await _visitTaskRepository.SaveChangesAsync();
+ return ResponseOutput.Ok();
+ }
+
+
+
+
+ ///
+ /// 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false)
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetSubjectAssignList(SubjectAssignQuery inQuery)
+ {
+ var subjectQuery = _subjectRepository.Where(t => t.TrialId == inQuery.TrialId)
+ .WhereIf(inQuery.IsJudgeDoctor == false, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
+ .WhereIf(inQuery.IsJudgeDoctor, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
+
+ .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.Id == inQuery.SubjectId)
+
+ .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == true && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
+ .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == true && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
+ .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == false && inQuery.IsJudgeDoctor == false, t => !t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
+ .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == false && inQuery.IsJudgeDoctor, t => !t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
+
+
+ .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == true && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).All(u => u.IsConfirmed))
+ .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == true && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).All(u => u.IsConfirmed))
+
+ .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == false && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any(u => u.IsConfirmed == false))
+ .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == false && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any(u => u.IsConfirmed == false))
+
+ .WhereIf(inQuery.DoctorUserId != null && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any(t => t.DoctorUserId == inQuery.DoctorUserId))
+ .WhereIf(inQuery.DoctorUserId != null && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any(t => t.DoctorUserId == inQuery.DoctorUserId))
+ .ProjectTo(_mapper.ConfigurationProvider, new { isJudgeDoctor = inQuery.IsJudgeDoctor });
+
+ var pageList = await subjectQuery.ToPagedListAsync(inQuery);
+
+ return pageList;
+ }
+
+
+ ///
+ /// 批量为 多个Subject 分配医生 手动分配 IsReAssign 为true 批量删除 重新分配
+ ///
+ ///
+ ///
+ [HttpPost]
+ [UnitOfWork]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ public async Task AssignSubjectDoctor(AssginSubjectDoctorCommand assginSubjectDoctorCommand)
+ {
+ var trialId = assginSubjectDoctorCommand.TrialId;
+ var doctorUserIdList = assginSubjectDoctorCommand.DoctorUserIdArmList.Select(t => t.DoctorUserId).ToList();
+
+ if (assginSubjectDoctorCommand.IsJudgeDoctor)
+ {
+ if (assginSubjectDoctorCommand.IsReAssign)
+ {
+
+ //if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm))
+ //{
+ // throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配");
+ //}
+
+
+ await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => doctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.ArmEnum == Arm.JudgeArm);
+ }
+
+
+ }
+ else
+ {
+ if (assginSubjectDoctorCommand.IsReAssign)
+ {
+
+ //if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum != Arm.JudgeArm))
+ //{
+ // throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配");
+ //}
+
+
+ await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => doctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.ArmEnum != Arm.JudgeArm);
+ }
+
+
+
+ }
+ foreach (var subjectId in assginSubjectDoctorCommand.SubjectIdList)
+ {
+ foreach (var doctorUserId in doctorUserIdList)
+ {
+
+ var armEnum = assginSubjectDoctorCommand.DoctorUserIdArmList.Where(t => t.DoctorUserId == doctorUserId).First().ArmEnum;
+
+
+ if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.ReplacedSubjectUserId == null))
+ {
+ //---有Subject 在其他Arm组已有该医生,不允许在新的组添加该医生
+ throw new BusinessValidationFailedException(_localizer["VisitTask_InconsistentSubjectStatus"]);
+ }
+
+ if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.ReplacedSubjectUserId == null))
+ {
+ //---有Subject 已有该Arm组的医生,不允许继续分配,请刷新页面,确认页面数据是否过期
+ throw new BusinessValidationFailedException(_localizer["VisitTask_DuplicateDoctorInArm"]);
+ }
+ else
+ {
+ await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subjectId, DoctorUserId = doctorUserId, ArmEnum = armEnum, AssignTime = DateTime.Now });
+
+ }
+
+ }
+
+ }
+
+
+ await _subjectUserRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok();
+ }
+
+ ///
+ /// 批量取消Subject 分配的医生
+ ///
+ /// 数量
+ [HttpPost]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ public async Task CancelSubjectAssignDoctor(CancelSubjectAssignCommand cancelSubjectAssignCommand)
+ {
+ if (cancelSubjectAssignCommand.IsJudgeDoctor)
+ {
+ foreach (var subjectId in cancelSubjectAssignCommand.SubjectIdList)
+ {
+ if (await _visitTaskRepository.AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm))
+ {
+ //---有Subject任务已应用,不允许取消分配
+ throw new BusinessValidationFailedException(_localizer["VisitTask_DoctorAlreadyInArm"]);
+ }
+
+ await _subjectUserRepository.DeleteFromQueryAsync(t => t.SubjectId == subjectId && t.ArmEnum == Arm.JudgeArm);
+ }
+ }
+ else
+ {
+ foreach (var subjectId in cancelSubjectAssignCommand.SubjectIdList)
+ {
+ if (await _visitTaskRepository.AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId != null && t.ArmEnum != Arm.JudgeArm))
+ {
+ //---有Subject任务已应用,不允许取消分配
+ throw new BusinessValidationFailedException(_localizer["VisitTask_DoctorAlreadyInArm"]);
+ }
+
+ await _subjectUserRepository.DeleteFromQueryAsync(t => t.SubjectId == subjectId && t.ArmEnum != Arm.JudgeArm);
+ }
+ }
+
+ await _subjectUserRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok();
+ }
+
+
+ ///
+ /// 手动分配确认 绑定该Subject的已存在的任务给医生
+ ///
+ ///
+ ///
+ [HttpPost]
+ [UnitOfWork]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ public async Task ManualAssignDoctorApplyTask(AssignConfirmCommand assignConfirmCommand)
+ {
+ var trialId = assignConfirmCommand.TrialId;
+
+ //获取项目配置 判断应该分配几个医生
+ //var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign, t.FollowGlobalVisitAutoAssignDefaultState, t.TaskAllocateObjEnum }).FirstOrDefaultAsync()).IfNullThrowException();
+
+ //需要确认的Subject
+ var subjectIdList = assignConfirmCommand.SubjectDoctorUserList.Select(t => t.SubjectId).ToList();
+
+ //将关系确认
+ if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
+ {
+ await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true });
+ }
+ else
+ {
+ await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null
+ && subjectIdList.Contains(t.SubjectId), u => new SubjectUser() { IsConfirmed = true });
+ }
+
+
+ var taskList = _visitTaskRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.DoctorUserId == null, true)
+ .WhereIf(subjectIdList.Count > 0 && assignConfirmCommand.IsJudgeDoctor == false, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
+ .WhereIf(subjectIdList.Count > 0 && assignConfirmCommand.IsJudgeDoctor, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
+ //过滤掉 那些回退的subject
+ .Where(t => !t.Subject.SubjectVisitList.Any(t => t.IsPMBackOrReReading))
+
+ .ToList();
+
+
+ foreach (var subjectTaskGroup in taskList.GroupBy(t => t.SubjectId))
+ {
+ var subjectId = subjectTaskGroup.Key;
+
+
+
+ //如果数据为空 那么就是确认所有已分配的
+ List subjectDoctorIdArmList = new List();
+
+ if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
+ {
+ subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList();
+ }
+ else
+ {
+ subjectDoctorIdArmList = assignConfirmCommand.SubjectDoctorUserList.Where(t => t.SubjectId == subjectId).First().DoctorUserIdArmList;
+ }
+
+
+ foreach (var task in subjectTaskGroup.OrderBy(t => t.ArmEnum).ToList())
+ {
+
+ var subjectDoctorArm = subjectDoctorIdArmList.Where(t => t.ArmEnum == task.ArmEnum).FirstOrDefault();
+
+ if (subjectDoctorArm != null)
+ {
+ task.DoctorUserId = subjectDoctorArm.DoctorUserId;
+ task.AllocateTime = DateTime.Now;
+ task.TaskAllocationState = TaskAllocationState.Allocated;
+
+ task.SuggesteFinishedTime = /*task.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7)*/ GetSuggessFinishTime(true, UrgentType.NotUrget);
+
+ await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == task.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading });
+
+ await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == task.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading });
+
+
+ }
+ else
+ {
+ //---在配置表中未找到配置的医生,无法应用绑定,请核对数据
+ throw new BusinessValidationFailedException(_localizer["VisitTask_TaskAlreadyApplied"]);
+ }
+
+ }
+ }
+
+
+
+ await _visitTaskRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok();
+ }
+
+
+
+ ///
+ /// 访视任务
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetVisitTaskList(VisitTaskQuery inQuery, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
+ {
+ //以前访视未产生任务的,在查询这里要产生
+ var svIdList = await _subjectVisitRepository.Where(t => t.TrialId == inQuery.TrialId && t.CheckState == CheckStateEnum.CVPassed && t.IsVisitTaskGenerated == false).Select(t => t.Id).ToListAsync();
+
+ //之前没有生成任务的逻辑 但是现在加了,任务要自动生成
+ await _visitTaskCommonService.GenerateVisitTaskAsync(inQuery.TrialId, svIdList);
+
+
+ var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsAnalysisCreate == false)
+ .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
+ .WhereIf(inQuery.ReadingCategory == null, t => t.ReadingCategory != ReadingCategory.Judge)
+
+ .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
+ .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
+ .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
+ .WhereIf(inQuery.DoctorUserId != null, t => t.DoctorUserId == inQuery.DoctorUserId)
+ .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
+ .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
+ .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
+
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
+ .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
+ .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+ var defalutSortArray = new string[] { nameof(VisitTaskView.IsUrgent) + " desc", nameof(VisitTaskView.SubjectCode), nameof(VisitTaskView.VisitTaskNum) };
+
+ var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+
+ //var trialTaskConfig = _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault();
+ return pageList;
+ }
+
+
+
+ ///
+ /// 裁判任务
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task/*, object)*/> GetJudgeVisitTaskList(VisitTaskQuery inQuery)
+ {
+
+ var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsAnalysisCreate == false)
+ .Where(t => t.ReadingCategory == ReadingCategory.Judge)
+
+ .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
+ .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
+ .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
+ .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
+ .WhereIf(inQuery.DoctorUserId != null, t => t.DoctorUserId == inQuery.DoctorUserId)
+ .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
+ .WhereIf(inQuery.ReadingTaskState != null, t => t.ReadingTaskState == inQuery.ReadingTaskState)
+ .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
+ .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
+ .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+ var defalutSortArray = new string[] { nameof(JudgeVisitTaskView.IsUrgent) + " desc", nameof(JudgeVisitTaskView.SubjectCode), nameof(JudgeVisitTaskView.VisitTaskNum) };
+
+ var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+
+ return pageList;
+ //var trialTaskConfig = _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault();
+
+ //return (pageList, trialTaskConfig);
+ }
+
+
+ ///
+ /// PM阅片跟踪
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task>> GetReadingTaskList(VisitTaskQuery inQuery)
+ {
+ var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsAnalysisCreate == false)
+ //.Where(t => t.IsAnalysisCreate == false && t.DoctorUserId != null)
+
+ .WhereIf(inQuery.IsEffect == true, t => t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze)
+ .WhereIf(inQuery.IsEffect == false, t => t.TaskState == TaskState.Adbandon || t.TaskState == TaskState.HaveReturned)
+
+ .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
+ .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
+ .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
+ .WhereIf(inQuery.DoctorUserId != null, t => t.DoctorUserId == inQuery.DoctorUserId)
+ .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
+ .WhereIf(inQuery.ReadingTaskState != null, t => t.ReadingTaskState == inQuery.ReadingTaskState)
+ .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
+ .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+ .WhereIf(inQuery.ReReadingApplyState != null, t => t.ReReadingApplyState == inQuery.ReReadingApplyState)
+
+ .WhereIf(inQuery.CompleteClinicalDataEnum == CompleteClinicalDataEnum.Complete, t => t.IsClinicalDataSign && t.IsNeedClinicalDataSign == true)
+ .WhereIf(inQuery.CompleteClinicalDataEnum == CompleteClinicalDataEnum.NotComplete, t => t.IsClinicalDataSign == false && t.IsNeedClinicalDataSign == true)
+ .WhereIf(inQuery.CompleteClinicalDataEnum == CompleteClinicalDataEnum.NA, t => t.IsNeedClinicalDataSign == false)
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
+ .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
+ .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate)
+ .WhereIf(inQuery.BeginSignTime != null, t => t.SignTime > inQuery.BeginSignTime)
+ .WhereIf(inQuery.EndSignTime != null, t => t.SignTime < inQuery.EndSignTime)
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+ var defalutSortArray = new string[] { nameof(ReadingTaskView.IsUrgent) + " desc", nameof(ReadingTaskView.SubjectCode), nameof(ReadingTaskView.VisitTaskNum) };
+
+ var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+
+ var trialTaskConfig = _trialRepository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault();
+
+ return ResponseOutput.Ok(pageList, trialTaskConfig);
+ }
+
+
+ ///
+ /// PM 重阅追踪
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReReadingTaskList(VisitTaskQuery inQuery)
{
+ var visitTaskQueryable = _visitTaskReReadingRepository
+ .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId /*&& t.OriginalReReadingTask.IsAnalysisCreate == false*/)
+ .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId)
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!))
+ .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState)
+ .WhereIf(inQuery.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == inQuery.ReReadingApplyState)
+ .WhereIf(inQuery.RequestReReadingType != null, t => t.RequestReReadingType == inQuery.RequestReReadingType)
+ .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId)
+ .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent)
+ .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId)
+ .WhereIf(inQuery.ArmEnum != null, t => t.OriginalReReadingTask.ArmEnum == inQuery.ArmEnum)
+ .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState)
+ .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState)
+ .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+ .WhereIf(inQuery.ReadingCategory != null, t => t.OriginalReReadingTask.ReadingCategory == inQuery.ReadingCategory)
- ///
- /// 设置任务加急
- ///
- ///
- ///
- [HttpPost]
- public async Task SetTaskUrgent(SetTaskUrgentInDto inDto)
+ .WhereIf(!string.IsNullOrEmpty(inQuery.RequestReReadingReason), t => t.RequestReReadingReason.Contains(inQuery.RequestReReadingReason))
+
+ .WhereIf(inQuery.RequestReReadingResultEnum != null, t => t.RequestReReadingResultEnum == inQuery.RequestReReadingResultEnum)
+
+
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.OriginalReReadingTask.TaskBlindName.Contains(inQuery.TaskName))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => ((t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) || t.OriginalReReadingTask.Subject.MedicalNo.Contains(inQuery.SubjectCode)) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate))
+ .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate)
+ .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
+
+ .WhereIf(inQuery.BeginRequestReReadingTime != null, t => t.RequestReReadingTime >= inQuery.BeginRequestReReadingTime)
+ .WhereIf(inQuery.EndRequestReReadingTime != null, t => t.RequestReReadingTime <= inQuery.EndRequestReReadingTime!.Value.AddDays(1))
+
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+ //var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
+
+ var defalutSortArray = new string[] {
+ nameof(ReReadingTaskView.RequestReReadingResultEnum) ,
+ nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc",
+ nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.TaskState),
+ nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectCode),nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
+
+
+
+ var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+
+ return pageList;
+ }
+
+
+ ///
+ /// 获取IR 重阅影像阅片列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetIRReReadingTaskList(VisitTaskQuery inQuery)
+ {
+
+ var visitTaskQueryable = _visitTaskReReadingRepository
+ .Where(t => t.RequestReReadingType == RequestReReadingType.DocotorApply)
+ .Where(t => t.OriginalReReadingTask.DoctorUserId == _userInfo.Id)
+ .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId)
+ .WhereIf(inQuery.RequestReReadingResultEnum != null, t => t.RequestReReadingResultEnum == inQuery.RequestReReadingResultEnum)
+ .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId)
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!))
+ .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState)
+ .WhereIf(inQuery.ReadingCategory != null, t => t.OriginalReReadingTask.ReadingCategory == inQuery.ReadingCategory)
+ .WhereIf(inQuery.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == inQuery.ReReadingApplyState)
+ .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId)
+ .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent)
+ .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId)
+ .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState)
+ .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState)
+ .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+
+
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.NewReReadingTask.TaskBlindName.Contains(inQuery.TaskName))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate))
+ .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate)
+ .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+
+
+ var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectCode), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
+
+ var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+
+ return pageList;
+ }
+
+
+ //SPM 能看到项目组申请记录
+ [HttpPost]
+ public async Task> GetSPMReReadingTaskList(VisitTaskQuery inQuery)
+ {
+ var visitTaskQueryable = _visitTaskReReadingRepository.Where(t => t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.OriginalReReadingTask.IsAnalysisCreate == false)
+ .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId)
+ .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId)
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!))
+ .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState)
+ .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId)
+ .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent)
+ .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId)
+ .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState)
+ .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState)
+ .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false))
+
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.NewReReadingTask.TaskBlindName.Contains(inQuery.TaskName))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate))
+ .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate)
+ .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+ var defalutSortArray = new string[] { nameof(ReReadingTaskView.RequestReReadingTime) };
+
+ //var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
+
+ var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+
+ return pageList;
+ }
+
+
+
+ ///
+ /// IR 待阅片任务列表
+ ///
+ ///
+ [HttpPost]
+ public async Task>> GetIRUnReadSubjectTaskList(IRUnReadSubjectQuery inQuery)
+ {
+
+ var trialId = inQuery.TrialId;
+ var subjectCode = inQuery.SubjectCode;
+
+ var trialReadingCriterionId = inQuery.TrialReadingCriterionId;
+
+ var criterionConfig = await _trialReadingCriterionRepository.Where(x => x.Id == inQuery.TrialReadingCriterionId).FirstNotNullAsync();
+
+ var readingTool = criterionConfig.ReadingTool;
+ var isReadingTaskViewInOrder = criterionConfig.IsReadingTaskViewInOrder;
+
+
+ var result = new PageOutput()
{
- await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
- {
- IsUrgent = inDto.IsUrgent,
- TaskUrgentType = inDto.TaskUrgentType,
- TaskUrgentRemake = inDto.TaskUrgentRemake,
+ PageSize = inQuery.PageSize,
+ PageIndex = inQuery.PageIndex,
+ TotalCount = 0,
+ CurrentPageData = null,
+ };
+ IRUnReadOutDto iRUnReadOut = new IRUnReadOutDto();
+
+ //subject 级别 有序 无序查询
+ if (isReadingTaskViewInOrder == ReadingOrder.InOrder || isReadingTaskViewInOrder == ReadingOrder.SubjectRandom)
+ {
+ result = await GetSubjectReadingIQueryable(new GetReadingIQueryableInDto()
+ {
+ TrialId = trialId,
+ TrialReadingCriterionId = trialReadingCriterionId,
+ SubjectCode = inQuery.SubjectCode,
+
+ PageIndex = inQuery.PageIndex,
+ PageSize = inQuery.PageSize,
+ Asc = inQuery.Asc,
+ SortField = inQuery.SortField,
});
-
- return await _visitTaskRepository.SaveChangesAsync();
+
+ }
+ //随机阅片
+ else
+ {
+ var taskQuery = _visitTaskRepository.Where(x => x.TrialId == inQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect && x.TrialReadingCriterionId == trialReadingCriterionId)
+ .Where(x => !x.Subject.IsDeleted).Where(x => (x.IsNeedClinicalDataSign && x.IsClinicalDataSign) || !x.IsNeedClinicalDataSign);
+
+ iRUnReadOut = new IRUnReadOutDto()
+ {
+ FinishJudgeTaskCount = await taskQuery.Where(x => x.ReadingCategory == ReadingCategory.Judge && x.ReadingTaskState == ReadingTaskState.HaveSigned).CountAsync(),
+ FinishTaskCount = await taskQuery.Where(x => x.ReadingCategory != ReadingCategory.Judge && x.ReadingTaskState == ReadingTaskState.HaveSigned).CountAsync(),
+ SuggesteFinishedTime = await taskQuery.Where(x => x.ReadingTaskState != ReadingTaskState.HaveSigned).MaxAsync(x => x.SuggesteFinishedTime),
+ UnReadJudgeTaskCount = await taskQuery.Where(x => x.ReadingCategory == ReadingCategory.Judge && x.ReadingTaskState != ReadingTaskState.HaveSigned).CountAsync(),
+ UnReadTaskCount = await taskQuery.Where(x => x.ReadingCategory != ReadingCategory.Judge && x.ReadingTaskState != ReadingTaskState.HaveSigned).CountAsync(),
+ };
}
- public async Task> GetTrialCriterionList(Guid trialId, bool isHaveSigned = true, bool? isAutoCreate = null)
+ return ResponseOutput.Ok(result, new
{
- var list = await _readingQuestionCriterionTrialRepository.Where(t => t.TrialId == trialId && t.IsConfirm)
+ IsReadingTaskViewInOrder = isReadingTaskViewInOrder,
+ RandomReadInfo = iRUnReadOut,
+ ReadingTool = readingTool,
+ IseCRFShowInDicomReading = criterionConfig.IseCRFShowInDicomReading,
+ IsReadingShowSubjectInfo = criterionConfig.IsReadingShowSubjectInfo,
+ IsReadingShowPreviousResults = criterionConfig.IsReadingShowPreviousResults,
+ DigitPlaces = criterionConfig.DigitPlaces,
+ CriterionType = criterionConfig.CriterionType,
+ });
- .OrderBy(t => t.ShowOrder)
- .Select(t => new TrialReadingCriterionDto()
+
+ }
+
+ ///
+ /// 获取subject有序 或者无序阅片IQuery对象
+ ///
+ ///
+ ///
+ public async Task> GetSubjectReadingIQueryable(GetReadingIQueryableInDto inQuery)
+ {
+ var trialReadingCriterionId = inQuery.TrialReadingCriterionId;
+ var subjectCode = inQuery.SubjectCode;
+ var trialId = inQuery.TrialId;
+ var subjectId = inQuery.SubjectId;
+
+ var critrion = await _trialReadingCriterionRepository.FindAsync(trialReadingCriterionId);
+
+ if (critrion.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ {
+ var visitQuery = _visitTaskRepository.Where(x => x.TrialId == inQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect)
+
+ .WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId)
+ //前序 不存在 未生成任务的访视
+ .WhereIf(critrion.IsAutoCreate == false, t => !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum))
+
+ // 前序 不存在 未一致性核查未通过的
+ .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum >= sv.VisitNum))
+ //.WhereIf(critrion.IsAutoCreate == false, t => t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId).Any(t => t.IsGeneratedTask == false) ?
+ //t.VisitTaskNum <= t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.IsGeneratedTask == false).Min(t => t.SubjectVisit.VisitNum) : true)
+ //.Where(t => t.Subject.SubjectVisitList.Any(t => t.CheckState != CheckStateEnum.CVPassed) ? t.VisitTaskNum <= t.Subject.SubjectVisitList.Where(t => t.CheckState != CheckStateEnum.CVPassed).Min(t => t.VisitNum) : true)
+ //满足前序访视不存在 需要签署但是未签署 sql 相当复杂 同时想查询所有未读的统计数字 就无法统计 byzhouhang
+ //但是加字段 IsFrontTaskNeedSignButNotSign 那么签名临床数据的时候,要对该subject 该标准的有效的任务 这个字段需要在签名的时候维护 采取这种方式 统计数字灵活
+ //.Where(t => t.Subject.SubjectVisitTaskList.AsQueryable().Where(visitTaskLambda).Any(c => c.IsNeedClinicalDataSign == true && c.IsClinicalDataSign == false && c.VisitTaskNum < t.VisitTaskNum))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode!) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode!) && t.IsAnalysisCreate));
+
+
+ var visitGroupQuery = visitQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode });
+
+ var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView()
+ {
+ SubjectId = x.Key.SubjectId,
+ SubjectCode = x.Key.BlindSubjectCode == string.Empty ? x.Key.Code : x.Key.BlindSubjectCode,
+
+ SuggesteFinishedTime = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Min(x => x.SuggesteFinishedTime),
+
+ //未读任务量
+ UnReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Count(),
+
+ //未读 里可读任务量
+ UnReadCanReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned && y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)
+ //不能对包含聚合或子查询的表达式执行聚合函数
+ //&& !x.Any(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.IsNeedClinicalDataSign == true && t.IsClinicalDataSign == false && t.VisitTaskNum y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned)
+ .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true))
+ .OrderBy(x => x.VisitTaskNum)
+ .Select(u => new IRUnreadTaskView()
{
- TrialReadingCriterionId = t.Id,
- IsAutoCreate = t.IsAutoCreate,
- IsAdditionalAssessment = t.IsAdditionalAssessment,
- TrialReadingCriterionName = t.CriterionName,
- CriterionType = t.CriterionType,
- ReadingType = t.ReadingType,
- ReadingInfoSignTime = t.ReadingInfoSignTime,
- IsReadingPeriod = t.IsReadingPeriod,
- IsArbitrationReading = t.IsArbitrationReading,
- IsGlobalReading = t.IsGlobalReading,
- IsOncologyReading = t.IsOncologyReading,
- ImageDownloadEnum = t.ImageDownloadEnum,
- ImageUploadEnum = t.ImageUploadEnum,
- IsReadingTaskViewInOrder = t.IsReadingTaskViewInOrder
+ Id = u.Id,
+ IsUrgent = u.IsUrgent,
+ VisitNum = u.VisitTaskNum,
+ TaskBlindName = u.TaskBlindName,
+ VisistId = u.SourceSubjectVisitId,
+ SuggesteFinishedTime = u.SuggesteFinishedTime,
+ ReadingCategory = u.ReadingCategory,
+ IsAnalysisCreate = u.IsAnalysisCreate,
+ ArmEnum = u.ArmEnum,
+ TrialReadingCriterionId = u.TrialReadingCriterionId,
+ IsNeedClinicalDataSign = u.IsNeedClinicalDataSign,
+ IsClinicalDataSign = u.IsClinicalDataSign,
+ IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign
})
- .ToListAsync();
-
- //if (list.Count == 0)
- //{
- // //---该项目还未确认任何一个阅片标准
- // throw new BusinessValidationFailedException(_localizer["VisitTask_VisitTask_TaskAlreadyApplied"]);
-
- //}
+ .ToList(),
- return list.AsQueryable().WhereIf(isHaveSigned == true, t => t.ReadingInfoSignTime != null)
- .WhereIf(isAutoCreate == false, t => t.IsAutoCreate == isAutoCreate).ToList();
- }
+ UrgentCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned)
+ .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true))
+ .Where(x => x.IsUrgent).Count(),
+ //已读任务量
+ HaveReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState == ReadingTaskState.HaveSigned).Count(),
+ ExistReadingApply = x.Any(y => (y.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed && y.TrialReadingCriterionId == trialReadingCriterionId) || y.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed),
-
- ///
- /// Subject 任务类型 统计 +分配情况
- ///
- ///
- [HttpPost]
- public async Task>> GetSubjectAssignAndTaskStatList(SubjectAssignStatQuery inQuery)
- {
-
- var isAddtinoarlCriterion = await _trialReadingCriterionRepository.AnyAsync(t => t.Id == inQuery.TrialReadingCriterionId && t.IsAutoCreate == false);
-
- var subjectQuery = _subjectRepository.Where(t => t.TrialId == inQuery.TrialId && t.SubjectVisitTaskList.Any())
- .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.Id == inQuery.SubjectId)
- .WhereIf(inQuery.DoctorUserId != null, t => t.SubjectDoctorList.Any(t => t.DoctorUserId == inQuery.DoctorUserId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.Code.Contains(inQuery.SubjectCode))
- //未分配
- .WhereIf(inQuery.SubjectAllocateState == 0, t => !t.SubjectDoctorList.Any(t => t.AssignTime != null && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId))
- //已分配
- .WhereIf(inQuery.SubjectAllocateState == 1, t => t.SubjectDoctorList.Any(t => t.AssignTime != null && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId))
-
- .WhereIf(inQuery.ArmList.Count > 0, t => !inQuery.ArmList.Except(t.SubjectDoctorList.Where(t => t.AssignTime != null && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId).Select(c => c.ArmEnum)).Any())
-
-
- .WhereIf(isAddtinoarlCriterion, t => t.SubjectCriteriaEvaluationList.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId).Any(t => t.IsJoinEvaluation))
-
-
- .ProjectTo(_mapper.ConfigurationProvider, new { trialReadingCriterionId = inQuery.TrialReadingCriterionId });
-
-
- var pageList = await subjectQuery.ToPagedListAsync(inQuery,nameof(SubjectAssignStat.SubjectId));
-
-
-
- var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == inQuery.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsArbitrationReading, x.IsOncologyReading, x.IsGlobalReading }).FirstOrDefaultAsync()).IfNullThrowException();
-
- return ResponseOutput.Ok(pageList, criterionConfig);
- }
-
- ///
- /// 一次性分配所有医生 批量分配(添加),后端现在没限制
- ///
- ///
- ///
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task BatchAssignDoctorToSubject(BatchAssignDoctorToSubjectCommand command)
- {
- //var inOrder = _trialRepository.Where(t => t.Id == command.TrialId).Select(t => t.IsReadingTaskViewInOrder).FirstOrDefault();
-
- //var inOrder = _trialReadingCriterionRepository.Where(t => t.Id == command.TrialReadingCriterionId).Select(t => t.IsReadingTaskViewInOrder).FirstOrDefault();
-
-
- foreach (var subjectId in command.SubjectIdList)
- {
- foreach (var doctorArm in command.DoctorArmList)
+ //查出所有未读的 未读的可读的 在这个列表基础上 过滤下 y.IsFrontTaskNeedSignButNotSign==false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true) 这样容易排错 确认这三个字段是否维护有误
+ UnReadTaskList = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).OrderBy(x => x.VisitTaskNum)
+ .Select(u => new IRUnreadTaskView()
{
- if (!await _subjectUserRepository.Where(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId).AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.ReplacedSubjectUserId == null))
- {
- await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = command.TrialId, TrialReadingCriterionId = command.TrialReadingCriterionId, ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now });
+ Id = u.Id,
+ IsUrgent = u.IsUrgent,
+ VisitNum = u.VisitTaskNum,
+ TaskBlindName = u.TaskBlindName,
+ VisistId = u.SourceSubjectVisitId,
+ SuggesteFinishedTime = u.SuggesteFinishedTime,
+ ReadingCategory = u.ReadingCategory,
+ IsAnalysisCreate = u.IsAnalysisCreate,
+ ArmEnum = u.ArmEnum,
+ TrialReadingCriterionId = u.TrialReadingCriterionId,
+ IsNeedClinicalDataSign = u.IsNeedClinicalDataSign,
+ IsClinicalDataSign = u.IsClinicalDataSign,
+ IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign
+ })
+ .ToList(),
+ }).Where(x => x.UnReadCanReadTaskCount > 0)/*.OrderBy(x => x.UnReadCanReadTaskCount)*/;
+ // 有序阅片需要找到最小需要
- //task.SuggesteFinishedTime = task.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7);
- }
+ // 不这样写会有问题
+ var count = visitQuery.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned && y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true))
+ .GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode }).Count();
+ var result = new List();
- Expression> updateWhere = t => t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false;
+ var propName = string.IsNullOrWhiteSpace(inQuery!.SortField) ? nameof(IRUnReadSubjectView.UnReadCanReadTaskCount) : inQuery.SortField;
- //if (inOrder)
- //{
- // //针对有序阅片 只分配< 最小的 不是一致性核查通过状态 和不是失访 的访视 的任务
- // if (await _subjectVisitRepository.AnyAsync(t => t.SubjectId == subjectId && t.CheckState != CheckStateEnum.CVPassed && t.IsLostVisit == false))
- // {
- // var notCheckPassedMinVisitNum = await _subjectVisitRepository.Where(t => t.SubjectId == subjectId && t.CheckState != CheckStateEnum.CVPassed).OrderBy(t => t.VisitNum).Select(t => t.VisitNum).FirstOrDefaultAsync();
+ var visitTaskOrderQuery = inQuery.Asc ? visitTaskQuery.OrderBy(propName) : visitTaskQuery.OrderBy(propName + " desc");
- // updateWhere = updateWhere.And(t => t.VisitTaskNum < notCheckPassedMinVisitNum);
- // }
- //}
+ result = await visitTaskOrderQuery
+ .Skip((inQuery.PageIndex - 1) * inQuery.PageSize)
+ .Take(inQuery.PageSize).ToListAsync();
- await _visitTaskRepository
- .UpdatePartialFromQueryAsync(updateWhere,
- u => new VisitTask()
- {
- AllocateTime = DateTime.Now,
- DoctorUserId = doctorArm.DoctorUserId,
- TaskAllocationState = TaskAllocationState.Allocated,
-
- SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget),
- });
- }
- }
-
- await _subjectUserRepository.SaveChangesAsync();
-
-
-
-
-
- return ResponseOutput.Ok();
- }
-
-
-
- ///
- /// 阅片人维度 Subject统计表
- ///
- ///
- ///
- ///
- public async Task<(List, object)> GetDoctorSubjectStat(Guid trialId, Guid trialReadingCriterionId)
- {
- var list = await _taskAllocationRuleRepository.Where(t => t.TrialId == trialId)
- .Where(t => t.Enroll.EnrollReadingCategoryList.Any(t => t.TrialReadingCriterionId == trialReadingCriterionId))
- .ProjectTo(_mapper.ConfigurationProvider, new { trialReadingCriterionId = trialReadingCriterionId }).ToListAsync();
-
- var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsArbitrationReading, x.IsOncologyReading }).FirstOrDefaultAsync()).IfNullThrowException();
-
- return (list, criterionConfig);
- }
-
-
- ///
- /// 获取Subject 分配医生情况
- ///
- ///
- ///
- ///
- public async Task<(List, object)> GetSubjectAssignedDoctorList(Guid subjectId, Guid trialReadingCriterionId)
- {
- var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed && t.TrialReadingCriterionId == trialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
-
- var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsGlobalReading, x.IsOncologyReading, x.IsArbitrationReading }).FirstOrDefaultAsync()).IfNullThrowException();
-
- return (list, criterionConfig);
- }
-
-
- ///
- /// 取消Subject 分配的医生
- ///
- ///
- ///
- ///
- [HttpPost]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task CancelSubjectAssignedDoctor(CancelSubjectDoctorCommand cancelCommand)
- {
- foreach (var command in cancelCommand.CancelList.Where(t => t.IsCancelAssign))
- {
- if (await _visitTaskRepository.AnyAsync(t => t.TaskState == TaskState.Effect && t.TrialReadingCriterionId == cancelCommand.TrialReadingCriterionId && t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState != ReadingTaskState.WaitReading))
- {
- //---当前医生已开始做该Subject 该标准的任务,不允许取消分配
- throw new BusinessValidationFailedException(_localizer["VisitTask_DoctorConfigNotFound"]);
- }
-
- await _subjectUserRepository.DeleteFromQueryAsync(t => t.Id == command.Id);
-
- await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterionId == cancelCommand.TrialReadingCriterionId && t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false, u => new VisitTask()
- {
- AllocateTime = null,
- DoctorUserId = null,
- TaskAllocationState = TaskAllocationState.NotAllocate,
- SuggesteFinishedTime = null
- });
- }
-
- var subjectId = cancelCommand.CancelList.First().SubjectId;
-
- await _subjectCanceDoctorRepository.AddAsync(new SubjectCanceDoctor() { SubjectId = subjectId, Note = cancelCommand.Note, TrialReadingCriterionId = cancelCommand.TrialReadingCriterionId });
-
- await _visitTaskRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok();
- }
-
-
-
-
- ///
- /// 任务 手动分配 重新分配 确认 取消分配
- /// 分配
- ///
- ///
- [HttpPost]
- [UnitOfWork]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task AssignSubjectTaskToDoctor(AssignSubjectTaskToDoctorCommand assignSubjectTaskToDoctorCommand)
- {
- var visitTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == assignSubjectTaskToDoctorCommand.Id);
-
- if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Assign || assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign)
- {
- //手动分配验证规则
-
- if (visitTask.SourceSubjectVisitId != null)
- {
-
- if (await _visitTaskRepository.AnyAsync(t => t.SourceSubjectVisitId == visitTask.SourceSubjectVisitId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id))
- {
- //---其中一个任务已分配给该医生,不允许分配
- return ResponseOutput.NotOk(_localizer["VisitTask_BackendDataError"]);
- }
- }
- else if (visitTask.SouceReadModuleId != null)
- {
- if (await _visitTaskRepository.AnyAsync(t => t.SouceReadModuleId == visitTask.SouceReadModuleId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id))
- {
- //---其中一个任务已分配给该医生,不允许分配
- return ResponseOutput.NotOk(_localizer["VisitTask_BackendDataError"]);
- }
- }
- else
- {
- //---出现脏数据 任务来源字段没有值
- throw new BusinessValidationFailedException(_localizer["VisitTask_DirtyData"]);
- }
-
- //PM 回退了 但是还没生成任务 当前任务编号前有访视进行了回退就不允许分配
- if (await _subjectVisitRepository.AnyAsync(t => t.SubjectId == visitTask.SubjectId && t.IsPMBackOrReReading && t.VisitNum <= visitTask.VisitTaskNum))
- {
- //---该受试者有访视进入了退回流程,还未经过一致性核查通过,不允许分配
- return ResponseOutput.NotOk(_localizer["VisitTask_MissingTaskSource"]);
- }
-
-
- visitTask.AllocateTime = DateTime.Now;
- visitTask.DoctorUserId = assignSubjectTaskToDoctorCommand.DoctorUserId;
- visitTask.TaskAllocationState = TaskAllocationState.Allocated;
-
- visitTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget);
-
-
-
- //await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading });
-
- //await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading });
- }
-
- else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign)
- {
- //验证 是不是两个任务都给了同一个医生
-
-
-
- //是否删除配置规则表里的 Subject 医生绑定关系 重新添加绑定关系
-
- //是否其该Subject 其他访视 绑定的医生 也同时变更?
-
-
- }
-
- else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Confirm)
- {
- visitTask.TaskAllocationState = TaskAllocationState.Allocated;
- }
- else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.CancelAssign)
- {
- visitTask.AllocateTime = null;
- visitTask.DoctorUserId = null;
- visitTask.TaskAllocationState = TaskAllocationState.NotAllocate;
-
- //await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.TaskAllocate });
-
- //await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.TaskAllocate });
- }
- await _visitTaskRepository.SaveChangesAsync();
- return ResponseOutput.Ok();
- }
-
-
-
-
- ///
- /// 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false)
- ///
- ///
- [HttpPost]
- public async Task> GetSubjectAssignList(SubjectAssignQuery inQuery)
- {
- var subjectQuery = _subjectRepository.Where(t => t.TrialId == inQuery.TrialId)
- .WhereIf(inQuery.IsJudgeDoctor == false, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
- .WhereIf(inQuery.IsJudgeDoctor, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
-
- .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.Id == inQuery.SubjectId)
-
- .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == true && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
- .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == true && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
- .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == false && inQuery.IsJudgeDoctor == false, t => !t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
- .WhereIf(inQuery.IsHaveAssigned != null && inQuery.IsHaveAssigned == false && inQuery.IsJudgeDoctor, t => !t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
-
-
- .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == true && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).All(u => u.IsConfirmed))
- .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == true && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).All(u => u.IsConfirmed))
-
- .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == false && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any(u => u.IsConfirmed == false))
- .WhereIf(inQuery.IsAssignConfirmed != null && inQuery.IsAssignConfirmed == false && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any(u => u.IsConfirmed == false))
-
- .WhereIf(inQuery.DoctorUserId != null && inQuery.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any(t => t.DoctorUserId == inQuery.DoctorUserId))
- .WhereIf(inQuery.DoctorUserId != null && inQuery.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any(t => t.DoctorUserId == inQuery.DoctorUserId))
- .ProjectTo(_mapper.ConfigurationProvider, new { isJudgeDoctor = inQuery.IsJudgeDoctor });
-
- var pageList = await subjectQuery.ToPagedListAsync(inQuery);
-
- return pageList;
- }
-
-
- ///
- /// 批量为 多个Subject 分配医生 手动分配 IsReAssign 为true 批量删除 重新分配
- ///
- ///
- ///
- [HttpPost]
- [UnitOfWork]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task AssignSubjectDoctor(AssginSubjectDoctorCommand assginSubjectDoctorCommand)
- {
- var trialId = assginSubjectDoctorCommand.TrialId;
- var doctorUserIdList = assginSubjectDoctorCommand.DoctorUserIdArmList.Select(t => t.DoctorUserId).ToList();
-
- if (assginSubjectDoctorCommand.IsJudgeDoctor)
- {
- if (assginSubjectDoctorCommand.IsReAssign)
- {
-
- //if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm))
- //{
- // throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配");
- //}
-
-
- await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => doctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.ArmEnum == Arm.JudgeArm);
- }
-
-
- }
- else
- {
- if (assginSubjectDoctorCommand.IsReAssign)
- {
-
- //if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum != Arm.JudgeArm))
- //{
- // throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配");
- //}
-
-
- await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => doctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.ArmEnum != Arm.JudgeArm);
- }
-
-
-
- }
- foreach (var subjectId in assginSubjectDoctorCommand.SubjectIdList)
- {
- foreach (var doctorUserId in doctorUserIdList)
- {
-
- var armEnum = assginSubjectDoctorCommand.DoctorUserIdArmList.Where(t => t.DoctorUserId == doctorUserId).First().ArmEnum;
-
-
- if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.ReplacedSubjectUserId == null))
- {
- //---有Subject 在其他Arm组已有该医生,不允许在新的组添加该医生
- throw new BusinessValidationFailedException(_localizer["VisitTask_InconsistentSubjectStatus"]);
- }
-
- if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.ReplacedSubjectUserId == null))
- {
- //---有Subject 已有该Arm组的医生,不允许继续分配,请刷新页面,确认页面数据是否过期
- throw new BusinessValidationFailedException(_localizer["VisitTask_DuplicateDoctorInArm"]);
- }
- else
- {
- await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subjectId, DoctorUserId = doctorUserId, ArmEnum = armEnum, AssignTime = DateTime.Now });
-
- }
-
- }
-
- }
-
-
- await _subjectUserRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok();
- }
-
- ///
- /// 批量取消Subject 分配的医生
- ///
- /// 数量
- [HttpPost]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task CancelSubjectAssignDoctor(CancelSubjectAssignCommand cancelSubjectAssignCommand)
- {
- if (cancelSubjectAssignCommand.IsJudgeDoctor)
- {
- foreach (var subjectId in cancelSubjectAssignCommand.SubjectIdList)
- {
- if (await _visitTaskRepository.AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm))
- {
- //---有Subject任务已应用,不允许取消分配
- throw new BusinessValidationFailedException(_localizer["VisitTask_DoctorAlreadyInArm"]);
- }
-
- await _subjectUserRepository.DeleteFromQueryAsync(t => t.SubjectId == subjectId && t.ArmEnum == Arm.JudgeArm);
- }
- }
- else
- {
- foreach (var subjectId in cancelSubjectAssignCommand.SubjectIdList)
- {
- if (await _visitTaskRepository.AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId != null && t.ArmEnum != Arm.JudgeArm))
- {
- //---有Subject任务已应用,不允许取消分配
- throw new BusinessValidationFailedException(_localizer["VisitTask_DoctorAlreadyInArm"]);
- }
-
- await _subjectUserRepository.DeleteFromQueryAsync(t => t.SubjectId == subjectId && t.ArmEnum != Arm.JudgeArm);
- }
- }
-
- await _subjectUserRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok();
- }
-
-
- ///
- /// 手动分配确认 绑定该Subject的已存在的任务给医生
- ///
- ///
- ///
- [HttpPost]
- [UnitOfWork]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task ManualAssignDoctorApplyTask(AssignConfirmCommand assignConfirmCommand)
- {
- var trialId = assignConfirmCommand.TrialId;
-
- //获取项目配置 判断应该分配几个医生
- //var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign, t.FollowGlobalVisitAutoAssignDefaultState, t.TaskAllocateObjEnum }).FirstOrDefaultAsync()).IfNullThrowException();
-
- //需要确认的Subject
- var subjectIdList = assignConfirmCommand.SubjectDoctorUserList.Select(t => t.SubjectId).ToList();
-
- //将关系确认
- if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
- {
- await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true });
- }
- else
- {
- await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null
- && subjectIdList.Contains(t.SubjectId), u => new SubjectUser() { IsConfirmed = true });
- }
-
-
- var taskList = _visitTaskRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.DoctorUserId == null, true)
- .WhereIf(subjectIdList.Count > 0 && assignConfirmCommand.IsJudgeDoctor == false, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
- .WhereIf(subjectIdList.Count > 0 && assignConfirmCommand.IsJudgeDoctor, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
- //过滤掉 那些回退的subject
- .Where(t => !t.Subject.SubjectVisitList.Any(t => t.IsPMBackOrReReading))
-
- .ToList();
-
-
- foreach (var subjectTaskGroup in taskList.GroupBy(t => t.SubjectId))
- {
- var subjectId = subjectTaskGroup.Key;
-
-
-
- //如果数据为空 那么就是确认所有已分配的
- List subjectDoctorIdArmList = new List();
-
- if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
- {
- subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList();
- }
- else
- {
- subjectDoctorIdArmList = assignConfirmCommand.SubjectDoctorUserList.Where(t => t.SubjectId == subjectId).First().DoctorUserIdArmList;
- }
-
-
- foreach (var task in subjectTaskGroup.OrderBy(t => t.ArmEnum).ToList())
- {
-
- var subjectDoctorArm = subjectDoctorIdArmList.Where(t => t.ArmEnum == task.ArmEnum).FirstOrDefault();
-
- if (subjectDoctorArm != null)
- {
- task.DoctorUserId = subjectDoctorArm.DoctorUserId;
- task.AllocateTime = DateTime.Now;
- task.TaskAllocationState = TaskAllocationState.Allocated;
-
- task.SuggesteFinishedTime = /*task.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7)*/ GetSuggessFinishTime(true, UrgentType.NotUrget);
-
- await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == task.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading });
-
- await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == task.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading });
-
-
- }
- else
- {
- //---在配置表中未找到配置的医生,无法应用绑定,请核对数据
- throw new BusinessValidationFailedException(_localizer["VisitTask_TaskAlreadyApplied"]);
- }
-
- }
- }
-
-
-
- await _visitTaskRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok();
- }
-
-
-
- ///
- /// 访视任务
- ///
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetVisitTaskList(VisitTaskQuery inQuery, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
- {
- //以前访视未产生任务的,在查询这里要产生
- var svIdList = await _subjectVisitRepository.Where(t => t.TrialId == inQuery.TrialId && t.CheckState == CheckStateEnum.CVPassed && t.IsVisitTaskGenerated == false).Select(t => t.Id).ToListAsync();
-
- //之前没有生成任务的逻辑 但是现在加了,任务要自动生成
- await _visitTaskCommonService.GenerateVisitTaskAsync(inQuery.TrialId, svIdList);
-
-
- var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsAnalysisCreate == false)
- .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
- .WhereIf(inQuery.ReadingCategory == null, t => t.ReadingCategory != ReadingCategory.Judge)
-
- .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
- .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
- .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
- .WhereIf(inQuery.DoctorUserId != null, t => t.DoctorUserId == inQuery.DoctorUserId)
- .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
- .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
- .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
- .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
- .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
- .ProjectTo(_mapper.ConfigurationProvider);
-
- var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTask.VisitTaskNum) };
-
- var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
-
- //var trialTaskConfig = _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault();
- return pageList;
- }
-
-
-
- ///
- /// 裁判任务
- ///
- ///
- ///
- [HttpPost]
- public async Task/*, object)*/> GetJudgeVisitTaskList(VisitTaskQuery inQuery)
- {
-
- var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsAnalysisCreate == false)
- .Where(t => t.ReadingCategory == ReadingCategory.Judge)
-
- .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
- .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
- .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
- .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
- .WhereIf(inQuery.DoctorUserId != null, t => t.DoctorUserId == inQuery.DoctorUserId)
- .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
- .WhereIf(inQuery.ReadingTaskState != null, t => t.ReadingTaskState == inQuery.ReadingTaskState)
- .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
- .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
- .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
- .ProjectTo(_mapper.ConfigurationProvider);
-
- var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTaskView.VisitTaskNum) };
-
- var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
-
- return pageList;
- //var trialTaskConfig = _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault();
-
- //return (pageList, trialTaskConfig);
- }
-
-
- ///
- /// PM阅片跟踪
- ///
- ///
- ///
- [HttpPost]
- public async Task>> GetReadingTaskList(VisitTaskQuery inQuery)
- {
- var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsAnalysisCreate == false)
- //.Where(t => t.IsAnalysisCreate == false && t.DoctorUserId != null)
-
- .WhereIf(inQuery.IsEffect == true, t => t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze)
- .WhereIf(inQuery.IsEffect == false, t => t.TaskState == TaskState.Adbandon || t.TaskState == TaskState.HaveReturned)
-
- .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
- .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
- .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
- .WhereIf(inQuery.DoctorUserId != null, t => t.DoctorUserId == inQuery.DoctorUserId)
- .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
- .WhereIf(inQuery.ReadingTaskState != null, t => t.ReadingTaskState == inQuery.ReadingTaskState)
- .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
- .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
- .WhereIf(inQuery.ReReadingApplyState != null, t => t.ReReadingApplyState == inQuery.ReReadingApplyState)
-
- .WhereIf(inQuery.CompleteClinicalDataEnum == CompleteClinicalDataEnum.Complete, t => t.IsClinicalDataSign && t.IsNeedClinicalDataSign == true)
- .WhereIf(inQuery.CompleteClinicalDataEnum == CompleteClinicalDataEnum.NotComplete, t => t.IsClinicalDataSign == false && t.IsNeedClinicalDataSign == true)
- .WhereIf(inQuery.CompleteClinicalDataEnum == CompleteClinicalDataEnum.NA, t => t.IsNeedClinicalDataSign == false)
- .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
- .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
- .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate)
- .WhereIf(inQuery.BeginSignTime != null, t => t.SignTime > inQuery.BeginSignTime)
- .WhereIf(inQuery.EndSignTime != null, t => t.SignTime < inQuery.EndSignTime)
- .ProjectTo(_mapper.ConfigurationProvider);
-
- var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTask.VisitTaskNum) };
-
- var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
-
- var trialTaskConfig = _trialRepository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault();
-
- return ResponseOutput.Ok(pageList, trialTaskConfig);
- }
-
-
- ///
- /// PM 重阅追踪
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetReReadingTaskList(VisitTaskQuery inQuery)
- {
-
-
- var visitTaskQueryable = _visitTaskReReadingRepository
- .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId /*&& t.OriginalReReadingTask.IsAnalysisCreate == false*/)
- .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId)
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!))
- .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState)
- .WhereIf(inQuery.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == inQuery.ReReadingApplyState)
- .WhereIf(inQuery.RequestReReadingType != null, t => t.RequestReReadingType == inQuery.RequestReReadingType)
- .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId)
- .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent)
- .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId)
- .WhereIf(inQuery.ArmEnum != null, t => t.OriginalReReadingTask.ArmEnum == inQuery.ArmEnum)
- .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState)
- .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState)
- .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
- .WhereIf(inQuery.ReadingCategory != null, t => t.OriginalReReadingTask.ReadingCategory == inQuery.ReadingCategory)
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.RequestReReadingReason), t => t.RequestReReadingReason.Contains(inQuery.RequestReReadingReason))
-
- .WhereIf(inQuery.RequestReReadingResultEnum != null, t => t.RequestReReadingResultEnum == inQuery.RequestReReadingResultEnum)
-
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false))
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.OriginalReReadingTask.TaskBlindName.Contains(inQuery.TaskName))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => ((t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) || t.OriginalReReadingTask.Subject.MedicalNo.Contains(inQuery.SubjectCode)) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate))
- .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate)
- .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
-
- .WhereIf(inQuery.BeginRequestReReadingTime != null, t => t.RequestReReadingTime >= inQuery.BeginRequestReReadingTime)
- .WhereIf(inQuery.EndRequestReReadingTime != null, t => t.RequestReReadingTime <= inQuery.EndRequestReReadingTime!.Value.AddDays(1))
-
- .ProjectTo(_mapper.ConfigurationProvider);
-
- //var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
-
- var defalutSortArray = new string[] {
- nameof(ReReadingTaskView.RequestReReadingResultEnum) ,
- nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc",
- nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.TaskState),
- nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId),nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
-
-
-
- var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
-
- return pageList;
- }
-
-
- ///
- /// 获取IR 重阅影像阅片列表
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetIRReReadingTaskList(VisitTaskQuery inQuery)
- {
-
- var visitTaskQueryable = _visitTaskReReadingRepository
- .Where(t => t.RequestReReadingType == RequestReReadingType.DocotorApply)
- .Where(t => t.OriginalReReadingTask.DoctorUserId == _userInfo.Id)
- .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId)
- .WhereIf(inQuery.RequestReReadingResultEnum != null, t => t.RequestReReadingResultEnum == inQuery.RequestReReadingResultEnum)
- .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId)
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!))
- .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState)
- .WhereIf(inQuery.ReadingCategory != null, t => t.OriginalReReadingTask.ReadingCategory == inQuery.ReadingCategory)
- .WhereIf(inQuery.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == inQuery.ReReadingApplyState)
- .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId)
- .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent)
- .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId)
- .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState)
- .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState)
- .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
-
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false))
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.NewReReadingTask.TaskBlindName.Contains(inQuery.TaskName))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate))
- .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate)
- .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
- .ProjectTo(_mapper.ConfigurationProvider);
-
-
-
- var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
-
- var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
-
- return pageList;
- }
-
-
- //SPM 能看到项目组申请记录
- [HttpPost]
- public async Task> GetSPMReReadingTaskList(VisitTaskQuery inQuery)
- {
- var visitTaskQueryable = _visitTaskReReadingRepository.Where(t => t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.OriginalReReadingTask.IsAnalysisCreate == false)
- .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId)
- .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId)
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!))
- .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState)
- .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId)
- .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent)
- .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId)
- .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState)
- .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState)
- .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false))
-
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.NewReReadingTask.TaskBlindName.Contains(inQuery.TaskName))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate))
- .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate)
- .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
- .ProjectTo(_mapper.ConfigurationProvider);
-
- var defalutSortArray = new string[] { nameof(ReReadingTaskView.RequestReReadingTime) };
-
- //var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) };
-
- var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
-
- return pageList;
- }
-
-
-
- ///
- /// IR 待阅片任务列表
- ///
- ///
- [HttpPost]
- public async Task>> GetIRUnReadSubjectTaskList(IRUnReadSubjectQuery inQuery)
- {
-
- var trialId = inQuery.TrialId;
- var subjectCode = inQuery.SubjectCode;
-
- var trialReadingCriterionId = inQuery.TrialReadingCriterionId;
-
- var criterionConfig = await _trialReadingCriterionRepository.Where(x => x.Id == inQuery.TrialReadingCriterionId).FirstNotNullAsync();
-
- var readingTool = criterionConfig.ReadingTool;
- var isReadingTaskViewInOrder = criterionConfig.IsReadingTaskViewInOrder;
-
-
- var result = new PageOutput()
+ return new PageOutput()
{
PageSize = inQuery.PageSize,
PageIndex = inQuery.PageIndex,
- TotalCount = 0,
- CurrentPageData = null,
+ TotalCount = count,
+ CurrentPageData = result,
};
-
- IRUnReadOutDto iRUnReadOut = new IRUnReadOutDto();
-
- //subject 级别 有序 无序查询
- if (isReadingTaskViewInOrder == ReadingOrder.InOrder || isReadingTaskViewInOrder == ReadingOrder.SubjectRandom)
- {
- result = await GetSubjectReadingIQueryable(new GetReadingIQueryableInDto()
- {
- TrialId = trialId,
- TrialReadingCriterionId = trialReadingCriterionId,
- SubjectCode = inQuery.SubjectCode,
-
- PageIndex = inQuery.PageIndex,
- PageSize = inQuery.PageSize,
- Asc = inQuery.Asc,
- SortField = inQuery.SortField,
- });
-
- }
- //随机阅片
- else
- {
- var taskQuery = _visitTaskRepository.Where(x => x.TrialId == inQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect && x.TrialReadingCriterionId == trialReadingCriterionId)
- .Where(x => !x.Subject.IsDeleted).Where(x => (x.IsNeedClinicalDataSign && x.IsClinicalDataSign) || !x.IsNeedClinicalDataSign);
-
- iRUnReadOut = new IRUnReadOutDto()
- {
- FinishJudgeTaskCount = await taskQuery.Where(x => x.ReadingCategory == ReadingCategory.Judge && x.ReadingTaskState == ReadingTaskState.HaveSigned).CountAsync(),
- FinishTaskCount = await taskQuery.Where(x => x.ReadingCategory != ReadingCategory.Judge && x.ReadingTaskState == ReadingTaskState.HaveSigned).CountAsync(),
- SuggesteFinishedTime = await taskQuery.Where(x => x.ReadingTaskState != ReadingTaskState.HaveSigned).MaxAsync(x => x.SuggesteFinishedTime),
- UnReadJudgeTaskCount = await taskQuery.Where(x => x.ReadingCategory == ReadingCategory.Judge && x.ReadingTaskState != ReadingTaskState.HaveSigned).CountAsync(),
- UnReadTaskCount = await taskQuery.Where(x => x.ReadingCategory != ReadingCategory.Judge && x.ReadingTaskState != ReadingTaskState.HaveSigned).CountAsync(),
- };
- }
-
- return ResponseOutput.Ok(result, new
- {
- IsReadingTaskViewInOrder = isReadingTaskViewInOrder,
- RandomReadInfo = iRUnReadOut,
- ReadingTool = readingTool,
- IseCRFShowInDicomReading = criterionConfig.IseCRFShowInDicomReading,
- IsReadingShowSubjectInfo = criterionConfig.IsReadingShowSubjectInfo,
- IsReadingShowPreviousResults = criterionConfig.IsReadingShowPreviousResults,
- DigitPlaces = criterionConfig.DigitPlaces,
- CriterionType = criterionConfig.CriterionType,
- });
-
-
}
-
- ///
- /// 获取subject有序 或者无序阅片IQuery对象
- ///
- ///
- ///
- public async Task> GetSubjectReadingIQueryable(GetReadingIQueryableInDto inQuery)
+ else
{
- var trialReadingCriterionId = inQuery.TrialReadingCriterionId;
- var subjectCode = inQuery.SubjectCode;
- var trialId = inQuery.TrialId;
- var subjectId = inQuery.SubjectId;
- var critrion = await _trialReadingCriterionRepository.FindAsync(trialReadingCriterionId);
-
- if (critrion.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ if (subjectId != null)
{
- var visitQuery = _visitTaskRepository.Where(x => x.TrialId == inQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect)
+ //找到 非一致性分析,未签名,状态正常的 并且任务名称是TimePoint的 任务
+ var needDealTaskList = await _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.Id
+ && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskBlindName == "Timepoint" && t.ReadingCategory == ReadingCategory.Visit
+ && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze), true).ToListAsync();
- .WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId)
- //前序 不存在 未生成任务的访视
- .WhereIf(critrion.IsAutoCreate == false, t => !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum))
-
- // 前序 不存在 未一致性核查未通过的
- .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum >= sv.VisitNum))
- //.WhereIf(critrion.IsAutoCreate == false, t => t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId).Any(t => t.IsGeneratedTask == false) ?
- //t.VisitTaskNum <= t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.IsGeneratedTask == false).Min(t => t.SubjectVisit.VisitNum) : true)
- //.Where(t => t.Subject.SubjectVisitList.Any(t => t.CheckState != CheckStateEnum.CVPassed) ? t.VisitTaskNum <= t.Subject.SubjectVisitList.Where(t => t.CheckState != CheckStateEnum.CVPassed).Min(t => t.VisitNum) : true)
- //满足前序访视不存在 需要签署但是未签署 sql 相当复杂 同时想查询所有未读的统计数字 就无法统计 byzhouhang
- //但是加字段 IsFrontTaskNeedSignButNotSign 那么签名临床数据的时候,要对该subject 该标准的有效的任务 这个字段需要在签名的时候维护 采取这种方式 统计数字灵活
- //.Where(t => t.Subject.SubjectVisitTaskList.AsQueryable().Where(visitTaskLambda).Any(c => c.IsNeedClinicalDataSign == true && c.IsClinicalDataSign == false && c.VisitTaskNum < t.VisitTaskNum))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode!) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode!) && t.IsAnalysisCreate));
-
-
- var visitGroupQuery = visitQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode });
-
- var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView()
+ if (needDealTaskList.Count > 0)
{
- SubjectId = x.Key.SubjectId,
- SubjectCode = x.Key.BlindSubjectCode == string.Empty ? x.Key.Code : x.Key.BlindSubjectCode,
+ //已完成的访视任务数量(包含重阅的)
+ var haveFinishedTaskCount = await _visitTaskRepository.CountAsync(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.Id
+ && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit);
- SuggesteFinishedTime = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Min(x => x.SuggesteFinishedTime),
+ //已经处理过的任务名称的数量
- //未读任务量
- UnReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Count(),
-
- //未读 里可读任务量
- UnReadCanReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned && y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)
- //不能对包含聚合或子查询的表达式执行聚合函数
- //&& !x.Any(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.IsNeedClinicalDataSign == true && t.IsClinicalDataSign == false && t.VisitTaskNum t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.Id
+ && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit && t.TaskBlindName != "Timepoint");
- UnReadCanReadTaskList = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned)
- .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true))
- .OrderBy(x => x.VisitTaskNum)
- .Select(u => new IRUnreadTaskView()
+
+ //随机赋值编号 比如要处理5个任务,实例化一个包含1-5的数组,每次随机取出一个
+ List availableNumbers = Enumerable.Range(haveDealedTaskCount + haveFinishedTaskCount + 1, needDealTaskList.Count).ToList();
+ Random rng = new Random();
+ foreach (var visitTask in needDealTaskList)
{
- Id = u.Id,
- IsUrgent = u.IsUrgent,
- VisitNum = u.VisitTaskNum,
- TaskBlindName = u.TaskBlindName,
- VisistId = u.SourceSubjectVisitId,
- SuggesteFinishedTime = u.SuggesteFinishedTime,
- ReadingCategory = u.ReadingCategory,
- IsAnalysisCreate = u.IsAnalysisCreate,
- ArmEnum = u.ArmEnum,
- TrialReadingCriterionId = u.TrialReadingCriterionId,
- IsNeedClinicalDataSign = u.IsNeedClinicalDataSign,
- IsClinicalDataSign = u.IsClinicalDataSign,
- IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign
- })
- .ToList(),
+ int randomIndex = rng.Next(availableNumbers.Count);
+ visitTask.TaskBlindName = $"Timepoint Ran {availableNumbers[randomIndex]}";
- UrgentCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned)
- .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true))
- .Where(x => x.IsUrgent).Count(),
-
- //已读任务量
- HaveReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState == ReadingTaskState.HaveSigned).Count(),
-
- ExistReadingApply = x.Any(y => (y.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed && y.TrialReadingCriterionId == trialReadingCriterionId) || y.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed),
-
- //查出所有未读的 未读的可读的 在这个列表基础上 过滤下 y.IsFrontTaskNeedSignButNotSign==false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true) 这样容易排错 确认这三个字段是否维护有误
- UnReadTaskList = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).OrderBy(x => x.VisitTaskNum)
- .Select(u => new IRUnreadTaskView()
- {
- Id = u.Id,
- IsUrgent = u.IsUrgent,
- VisitNum = u.VisitTaskNum,
- TaskBlindName = u.TaskBlindName,
- VisistId = u.SourceSubjectVisitId,
- SuggesteFinishedTime = u.SuggesteFinishedTime,
- ReadingCategory = u.ReadingCategory,
- IsAnalysisCreate = u.IsAnalysisCreate,
- ArmEnum = u.ArmEnum,
- TrialReadingCriterionId = u.TrialReadingCriterionId,
- IsNeedClinicalDataSign = u.IsNeedClinicalDataSign,
- IsClinicalDataSign = u.IsClinicalDataSign,
- IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign
- })
- .ToList(),
- }).Where(x => x.UnReadCanReadTaskCount > 0)/*.OrderBy(x => x.UnReadCanReadTaskCount)*/;
- // 有序阅片需要找到最小需要
-
-
- // 不这样写会有问题
- var count = visitQuery.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned && y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true))
- .GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode }).Count();
-
- var result = new List();
-
- var propName = string.IsNullOrWhiteSpace(inQuery!.SortField) ? nameof(IRUnReadSubjectView.UnReadCanReadTaskCount) : inQuery.SortField;
-
- var visitTaskOrderQuery = inQuery.Asc ? visitTaskQuery.OrderBy(propName) : visitTaskQuery.OrderBy(propName + " desc");
-
-
-
- result = await visitTaskOrderQuery
- .Skip((inQuery.PageIndex - 1) * inQuery.PageSize)
- .Take(inQuery.PageSize).ToListAsync();
-
-
- return new PageOutput()
- {
- PageSize = inQuery.PageSize,
- PageIndex = inQuery.PageIndex,
- TotalCount = count,
- CurrentPageData = result,
- };
- }
- else
- {
-
- if (subjectId != null)
- {
- //找到 非一致性分析,未签名,状态正常的 并且任务名称是TimePoint的 任务
- var needDealTaskList = await _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.Id
- && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskBlindName == "Timepoint" && t.ReadingCategory == ReadingCategory.Visit
- && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze), true).ToListAsync();
-
- if (needDealTaskList.Count > 0)
- {
- //已完成的访视任务数量(包含重阅的)
- var haveFinishedTaskCount = await _visitTaskRepository.CountAsync(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.Id
- && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit);
-
- //已经处理过的任务名称的数量
-
- var haveDealedTaskCount = await _visitTaskRepository.CountAsync(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.Id
- && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit && t.TaskBlindName != "Timepoint");
-
-
-
- //随机赋值编号 比如要处理5个任务,实例化一个包含1-5的数组,每次随机取出一个
- List availableNumbers = Enumerable.Range(haveDealedTaskCount + haveFinishedTaskCount + 1, needDealTaskList.Count).ToList();
- Random rng = new Random();
- foreach (var visitTask in needDealTaskList)
- {
- int randomIndex = rng.Next(availableNumbers.Count);
-
- visitTask.TaskBlindName = $"Timepoint Ran {availableNumbers[randomIndex]}";
-
- availableNumbers.RemoveAt(randomIndex);
- }
- await _visitTaskRepository.SaveChangesAsync();
+ availableNumbers.RemoveAt(randomIndex);
}
+ await _visitTaskRepository.SaveChangesAsync();
}
-
- var visitQuery = _visitTaskRepository.Where(x => x.TrialId == trialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect)
- .WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId)
- .WhereIf(!string.IsNullOrEmpty(subjectCode), t => (t.Subject.Code.Contains(subjectCode!) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(subjectCode!) && t.IsAnalysisCreate));
-
- var visitGroupQuery = visitQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode });
-
- var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView()
- {
- SubjectId = x.Key.SubjectId,
- SubjectCode = x.Key.BlindSubjectCode == string.Empty ? x.Key.Code : x.Key.BlindSubjectCode,
-
- SuggesteFinishedTime = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Min(x => x.SuggesteFinishedTime),
-
- //未读任务量
- UnReadCanReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Count(),
-
- UrgentCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Where(x => x.IsUrgent).Count(),
-
- //已读任务量
- HaveReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState == ReadingTaskState.HaveSigned).Count(),
-
- ExistReadingApply = x.Any(y => (y.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed && y.TrialReadingCriterionId == trialReadingCriterionId) || y.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed),
-
- UnReadCanReadTaskList = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned)
- .OrderBy(x => x.VisitTaskNum)
- .Select(u => new IRUnreadTaskView()
- {
- Id = u.Id,
- IsUrgent = u.IsUrgent,
- VisitNum = u.VisitTaskNum,
- TaskBlindName = u.TaskBlindName,
- VisistId = u.SourceSubjectVisitId,
- SuggesteFinishedTime = u.SuggesteFinishedTime,
- ReadingCategory = u.ReadingCategory,
- IsAnalysisCreate = u.IsAnalysisCreate,
- ArmEnum = u.ArmEnum,
- TrialReadingCriterionId = u.TrialReadingCriterionId,
- IsNeedClinicalDataSign = u.IsNeedClinicalDataSign,
- IsClinicalDataSign = u.IsClinicalDataSign,
- IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign
- })
- .ToList()
- }).Where(x => x.UnReadCanReadTaskCount > 0);
-
- var pageList = await visitTaskQuery.ToPagedListAsync(inQuery, nameof(IRUnReadSubjectView.UnReadCanReadTaskCount) );
-
- return pageList;
}
- }
+ var visitQuery = _visitTaskRepository.Where(x => x.TrialId == trialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect)
+ .WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId)
+ .WhereIf(!string.IsNullOrEmpty(subjectCode), t => (t.Subject.Code.Contains(subjectCode!) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(subjectCode!) && t.IsAnalysisCreate));
+ var visitGroupQuery = visitQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode });
- ///
- /// IR 已阅片任务
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetIRHaveReadTaskList(VisitTaskQuery inQuery)
- {
+ var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView()
+ {
+ SubjectId = x.Key.SubjectId,
+ SubjectCode = x.Key.BlindSubjectCode == string.Empty ? x.Key.Code : x.Key.BlindSubjectCode,
+ SuggesteFinishedTime = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Min(x => x.SuggesteFinishedTime),
- var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId)
- .Where(t => t.DoctorUserId == _userInfo.Id && t.ReadingTaskState == ReadingTaskState.HaveSigned)//该医生 已经签名的数据
+ //未读任务量
+ UnReadCanReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Count(),
+ UrgentCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Where(x => x.IsUrgent).Count(),
- .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
- .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
- .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
- .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
- .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
- .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+ //已读任务量
+ HaveReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState == ReadingTaskState.HaveSigned).Count(),
+ ExistReadingApply = x.Any(y => (y.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed && y.TrialReadingCriterionId == trialReadingCriterionId) || y.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed),
- .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
- .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
- .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
- .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
- .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
- .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
- .ProjectTo(_mapper.ConfigurationProvider);
+ UnReadCanReadTaskList = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned)
+ .OrderBy(x => x.VisitTaskNum)
+ .Select(u => new IRUnreadTaskView()
+ {
+ Id = u.Id,
+ IsUrgent = u.IsUrgent,
+ VisitNum = u.VisitTaskNum,
+ TaskBlindName = u.TaskBlindName,
+ VisistId = u.SourceSubjectVisitId,
+ SuggesteFinishedTime = u.SuggesteFinishedTime,
+ ReadingCategory = u.ReadingCategory,
+ IsAnalysisCreate = u.IsAnalysisCreate,
+ ArmEnum = u.ArmEnum,
+ TrialReadingCriterionId = u.TrialReadingCriterionId,
+ IsNeedClinicalDataSign = u.IsNeedClinicalDataSign,
+ IsClinicalDataSign = u.IsClinicalDataSign,
+ IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign
+ })
+ .ToList()
+ }).Where(x => x.UnReadCanReadTaskCount > 0);
- var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTask.VisitTaskNum) };
-
- var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+ var pageList = await visitTaskQuery.ToPagedListAsync(inQuery, nameof(IRUnReadSubjectView.UnReadCanReadTaskCount) );
return pageList;
}
+ }
- [HttpPost]
- [UnitOfWork]
- public async Task AIRReReading(AIRReReadingCommand command, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
+ ///
+ /// IR 已阅片任务
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetIRHaveReadTaskList(VisitTaskQuery inQuery)
+ {
+
+
+ var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId)
+ .Where(t => t.DoctorUserId == _userInfo.Id && t.ReadingTaskState == ReadingTaskState.HaveSigned)//该医生 已经签名的数据
+
+
+ .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
+ .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
+ .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
+ .WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
+ .WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
+ .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
+
+
+ .WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
+ .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => (t.Subject.Code.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.IsAnalysisCreate))
+ .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
+ .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1))
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+ var defalutSortArray = new string[] { nameof(IRHaveReadView.IsUrgent) + " desc", nameof(IRHaveReadView.SubjectCode), nameof(IRHaveReadView.VisitTaskNum) };
+
+ var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray);
+
+ return pageList;
+ }
+
+
+
+ [HttpPost]
+ [UnitOfWork]
+ public async Task AIRReReading(AIRReReadingCommand command, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
+ {
+ var baseLineTaskList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id
+ && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SourceSubjectVisit.IsBaseLine == true).ToListAsync();
+
+ var judegeList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id
+ && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Judge && t.ReadingTaskState == ReadingTaskState.HaveSigned).ToListAsync();
+
+ foreach (var item in judegeList)
{
- var baseLineTaskList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id
- && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SourceSubjectVisit.IsBaseLine == true).ToListAsync();
-
- var judegeList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id
- && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Judge && t.ReadingTaskState == ReadingTaskState.HaveSigned).ToListAsync();
-
- foreach (var item in judegeList)
+ if (!baseLineTaskList.Any(t => t.SubjectId == item.SubjectId))
{
- if (!baseLineTaskList.Any(t => t.SubjectId == item.SubjectId))
- {
- baseLineTaskList.Add(item);
- }
+ baseLineTaskList.Add(item);
}
-
-
- var baseLineTaskIdList = baseLineTaskList.Select(t => t.Id).ToList();
-
- if (baseLineTaskIdList.Count == 0)
- {
- return ResponseOutput.Ok();
- }
-
- //if (baseLineTaskList == null)
- //{
- // return ResponseOutput.NotOk("基线任务未阅完,不允许重阅基线任务");
- //}
-
- await ApplyReReading(new ApplyReReadingCommand() { IsCopyFollowForms = false, IsCopyOrigenalForms = false, TaskIdList = baseLineTaskIdList, TrialId = command.TrialId, RequestReReadingReason = "AIR自动重阅基线", RequestReReadingType = RequestReReadingType.DocotorApply });
-
-
-
- var requestRecordList = await _visitTaskReReadingRepository.Where(t => baseLineTaskIdList.Contains(t.OriginalReReadingTaskId) && t.RequestReReadingUserId == _userInfo.Id && t.RequestReReadingReason == "AIR自动重阅基线").ToListAsync();
-
- if (requestRecordList.Count != baseLineTaskIdList.Count)
- {
- //---后台数据有错误
- return ResponseOutput.NotOk(_localizer["VisitTask_DoctorConfiguration"]);
- }
-
- await ConfirmReReading(new ConfirmReReadingCommand()
- {
- TrialId = command.TrialId,
- RequestReReadingResultEnum = RequestReReadingResult.Agree,
- //ConfirmReReadingList = new List() { new ConfirmReReadingDTO() { Id = requestRecord.Id, OriginalReReadingTaskId = task.Id } }
- ConfirmReReadingList = requestRecordList.Select(t => new ConfirmReReadingDTO() { Id = t.Id, OriginalReReadingTaskId = t.OriginalReReadingTaskId }).ToList()
- }, _visitTaskCommonService);
-
- return ResponseOutput.Ok();
-
}
+ var baseLineTaskIdList = baseLineTaskList.Select(t => t.Id).ToList();
- ///
- /// 申请重阅 1:IR 2:PM
- ///
- ///
- ///
- [HttpPost]
- [UnitOfWork]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
-
- public async Task ApplyReReading(ApplyReReadingCommand applyReReadingCommand)
+ if (baseLineTaskIdList.Count == 0)
{
-
-
- var taskList = await _visitTaskRepository.Where(t => applyReReadingCommand.TaskIdList.Contains(t.Id), true).ToListAsync();
-
- var trialReadingCriterionId = taskList.First()!.TrialReadingCriterionId;
-
- var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsAutoCreate, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
-
-
- foreach (var task in taskList)
- {
-
-
- if (task.ReadingTaskState != ReadingTaskState.HaveSigned || (task.TaskState != TaskState.Effect && task.TaskState != TaskState.Freeze))
- {
- //---未阅片完成,或者未生效的任务不允许申请重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_BackendData"]);
- }
-
- if (task.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || task.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed || task.ReReadingApplyState == ReReadingApplyState.Agree)
- {
- //---重阅已申请,或者重阅已同意状态下不允许申请重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_UnreadTask"]);
- }
-
-
-
-
- if (IsPMOrAPm())
- {
- if (criterionConfig.IsAutoCreate == false)
- {
- //---手动生成任务的不允许PM 申请影像重阅
- return ResponseOutput.NotOk(_localizer["VisitTask_NoPMRecheck"]);
- }
-
- if (task.IsAnalysisCreate)
- {
- //---PM 不允许对一致性分析任务进行申请重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_Reapply"]);
- }
-
- if (task.ReadingCategory != ReadingCategory.Visit)
- {
- //---PM 仅仅允许对访视类型的任务申请重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_ConsistencyAnalysis"]);
- }
-
-
- // 有序 一个受试者访视重阅未处理完,不能申请其他的
- if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
- {
- if (await _visitTaskReReadingRepository.AnyAsync(t => t.OriginalReReadingTask.TrialId == task.TrialId && t.OriginalReReadingTask.SubjectId == task.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect
- && t.OriginalReReadingTask.TrialReadingCriterionId == task.TrialReadingCriterionId
- && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default))
- {
- //---当前为有序阅片,该受试者已有访视已申请重阅还未处理(项目组申请),暂不能继续申请重阅
- return ResponseOutput.NotOk(_localizer["VisitTask_VisitTypeRestriction"]);
- }
- }
-
-
- task.ReReadingApplyState = ReReadingApplyState.TrialGroupHaveApplyed;
-
-
- }
- if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer)
- {
- task.ReReadingApplyState = ReReadingApplyState.DocotorHaveApplyed;
-
-
- //在PM 的申请重阅的影响列表里也不能申请重阅
-
- var pmApply = await _visitTaskReReadingRepository.Where(t => t.OriginalReReadingTask.TrialId == task.TrialId && t.OriginalReReadingTask.SubjectId == task.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect && t.OriginalReReadingTask.ReadingCategory == ReadingCategory.Visit
- && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default).Include(t => t.OriginalReReadingTask).FirstOrDefaultAsync();
-
-
- // 有序
- if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
- {
- // 针对同一个subject 不同阅片人 针对同一个访视申请重阅,是允许的,所以同一阅片人,针对同一suject 有访视申请重阅还未处理,不允许申请重阅
- if (await _visitTaskReReadingRepository.AnyAsync(t => t.OriginalReReadingTask.TrialId == task.TrialId && t.OriginalReReadingTask.SubjectId == task.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect
- && t.OriginalReReadingTask.TrialReadingCriterionId == task.TrialReadingCriterionId && t.OriginalReReadingTask.DoctorUserId == task.DoctorUserId
- && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.RequestReReadingType == RequestReReadingType.DocotorApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default))
- {
- //---当前为有序阅片,该受试者已有访视已申请重阅还未处理,暂不能继续申请重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_SequentialReading"]);
- }
-
-
-
- if (pmApply != null)
- {
- var originalTask = pmApply.OriginalReReadingTask;
-
- //PM 有序影响列表
- if (await _visitTaskRepository.Where(t => t.TrialId == originalTask.TrialId && t.SubjectId == originalTask.SubjectId && t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated && t.IsAnalysisCreate == false && t.TrialReadingCriterionId == originalTask.TrialReadingCriterionId && t.VisitTaskNum >= originalTask.VisitTaskNum)
- .AnyAsync(t => t.VisitTaskNum == task.VisitTaskNum))
- {
- //---当前为有序阅片,影像存在问题,项目组已申请回退,暂不能申请重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_ImageProblem"]);
- }
-
- }
-
-
-
- Expression> filterExpression = t => t.TrialId == task.TrialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.TrialReadingCriterionId == task.TrialReadingCriterionId
- && t.DoctorUserId == task.DoctorUserId && t.IsAnalysisCreate == false && t.VisitTaskNum > task.VisitTaskNum;
-
-
-
- if (task.ReadingCategory == ReadingCategory.Global && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Global)))
- {
- //---有序阅片,只允许申请该受试者阅片人最后一次完成全局任务重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_LastReading"]);
- }
-
- if (task.ReadingCategory == ReadingCategory.Oncology && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Oncology && t.ReadingTaskState == ReadingTaskState.HaveSigned)))
- {
- //---有序阅片,只允许申请该受试者阅片人最后一次完成肿瘤学任务重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_LastOncologistRecheck"]);
- }
-
- if (task.ReadingCategory == ReadingCategory.Judge && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Judge && t.ReadingTaskState == ReadingTaskState.HaveSigned)))
- {
- //---有序阅片,只允许申请该受试者阅片人最后一次完成裁判的任务重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_LastAdjudicatorRecheck"]);
- }
-
- }
- else
- {
-
- if (pmApply != null)
- {
- var originalTask = pmApply.OriginalReReadingTask;
-
- //PM 无序影响列表
- if (await _visitTaskRepository.Where(t => t.TrialId == originalTask.TrialId && t.SubjectId == originalTask.SubjectId && t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated && t.IsAnalysisCreate == false && t.TrialReadingCriterionId == originalTask.TrialReadingCriterionId)
- .Where(t => t.Id == originalTask.Id || t.Id == originalTask.JudgeVisitTaskId)
- .AnyAsync(t => t.VisitTaskNum == task.VisitTaskNum))
- {
- //---当前为无序阅片,影像存在问题,项目组已申请回退,暂不能申请重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_RandomInvalidRereading"]);
- }
-
- }
-
- //也要支持裁判重阅240701
-
- if (task.ReadingCategory != ReadingCategory.Visit && task.ReadingCategory != ReadingCategory.Judge)
- {
- //---无序阅片,仅仅允许IR 申请 访视、裁判类型类别的任务进行重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_IRGlobalRecheck"]);
- }
- }
-
- }
-
- //AIR 不加验证
- if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR)
- {
- task.ReReadingApplyState = ReReadingApplyState.DocotorHaveApplyed;
- }
-
-
-
- var rootReReadingTaskId = _visitTaskReReadingRepository.Where(t => t.NewReReadingTaskId == task.Id).Select(u => u.RootReReadingTaskId).FirstOrDefault();
-
- //添加申请记录
- var visitTaskReReading = await _visitTaskReReadingRepository.AddAsync(new VisitTaskReReading()
- {
- TrialId = applyReReadingCommand.TrialId,
- RootReReadingTaskId = rootReReadingTaskId == Guid.Empty ? task.Id : rootReReadingTaskId,
- OriginalReReadingTaskId = task.Id,
- RequestReReadingTime = DateTime.Now,
- RequestReReadingUserId = _userInfo.Id,
- IsCopyOrigenalForms = applyReReadingCommand.IsCopyOrigenalForms,
- IsCopyFollowForms = applyReReadingCommand.IsCopyFollowForms,
- RequestReReadingReason = applyReReadingCommand.RequestReReadingReason,
- RequestReReadingType = applyReReadingCommand.RequestReReadingType,
-
- });
- }
-
-
- await _visitTaskRepository.SaveChangesAsync();
-
return ResponseOutput.Ok();
}
+ //if (baseLineTaskList == null)
+ //{
+ // return ResponseOutput.NotOk("基线任务未阅完,不允许重阅基线任务");
+ //}
- ///
- /// 重阅原任务跟踪处理
- ///
- ///
- ///
- ///
- private void ReReadingTaskTrackingDeal(VisitTask origenalTask, ConfirmReReadingCommand agreeReReadingCommand)
+ await ApplyReReading(new ApplyReReadingCommand() { IsCopyFollowForms = false, IsCopyOrigenalForms = false, TaskIdList = baseLineTaskIdList, TrialId = command.TrialId, RequestReReadingReason = "AIR自动重阅基线", RequestReReadingType = RequestReReadingType.DocotorApply });
+
+
+
+ var requestRecordList = await _visitTaskReReadingRepository.Where(t => baseLineTaskIdList.Contains(t.OriginalReReadingTaskId) && t.RequestReReadingUserId == _userInfo.Id && t.RequestReReadingReason == "AIR自动重阅基线").ToListAsync();
+
+ if (requestRecordList.Count != baseLineTaskIdList.Count)
{
- if (origenalTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || origenalTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
- {
- origenalTask.ReReadingApplyState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? ReReadingApplyState.Agree : ReReadingApplyState.Reject;
- origenalTask.TaskState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? TaskState.HaveReturned : origenalTask.TaskState;
- }
- else
- {
- //---当前重阅任务状态不为已申请状态,不允许进行处理,请刷新页面
- throw new BusinessValidationFailedException(_localizer["VisitTask_InvalidReapplyStatus"]);
- }
-
+ //---后台数据有错误
+ return ResponseOutput.NotOk(_localizer["VisitTask_DoctorConfiguration"]);
}
- private async Task SetMedicalReviewInvalidAsync(List influenceTaskList, bool isPMApply = true)
+ await ConfirmReReading(new ConfirmReReadingCommand()
{
- //将医学审核设置为失效
- var taskIdList = influenceTaskList.Select(t => t.Id).ToList();
+ TrialId = command.TrialId,
+ RequestReReadingResultEnum = RequestReReadingResult.Agree,
+ //ConfirmReReadingList = new List() { new ConfirmReReadingDTO() { Id = requestRecord.Id, OriginalReReadingTaskId = task.Id } }
+ ConfirmReReadingList = requestRecordList.Select(t => new ConfirmReReadingDTO() { Id = t.Id, OriginalReReadingTaskId = t.OriginalReReadingTaskId }).ToList()
+ }, _visitTaskCommonService);
- //PM 申请 医学审核任务状态为待审核、审核中的,设置为失效。
+ return ResponseOutput.Ok();
- //IR 申请 当前任务进入医学审核,医学审核任务未签名且结论中是否有问题项,答案为否的,设置为失效
+ }
- if (isPMApply)
- {
- await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.VisitTaskId) && t.AuditState != MedicalReviewAuditState.HaveSigned, u => new TaskMedicalReview() { IsInvalid = true });
- }
- else
- {
- await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.VisitTaskId) && t.IsHaveQuestion == false && t.AuditState != MedicalReviewAuditState.HaveSigned, u => new TaskMedicalReview() { IsInvalid = true });
- }
- }
+ ///
+ /// 申请重阅 1:IR 2:PM
+ ///
+ ///
+ ///
+ [HttpPost]
+ [UnitOfWork]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- ///
- /// PM 申请重阅 被同意 或者 PM 直接退回的时候影响
- ///
- ///
- ///
- private async Task PMReReadingConfirmOrBackInfluenceAnalysisAsync(Guid subjectId)
- {
- if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.SubjectId == subjectId))
- {
- await _subjectRepository.UpdatePartialFromQueryAsync(t => t.Id == subjectId, u => new Subject() { IsReReadingOrBackInfluenceAnalysis = true });
+ public async Task ApplyReReading(ApplyReReadingCommand applyReReadingCommand)
+ {
- }
- }
+ var taskList = await _visitTaskRepository.Where(t => applyReReadingCommand.TaskIdList.Contains(t.Id), true).ToListAsync();
- public DateTime GetSuggessFinishTime(bool isInOrder, UrgentType urgentType)
+ var trialReadingCriterionId = taskList.First()!.TrialReadingCriterionId;
+
+ var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsAutoCreate, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
+
+
+ foreach (var task in taskList)
{
- var datetime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 22, 0, 0).AddDays(7);
- return datetime;
- }
-
- ///
- /// 确认重阅与否 1同意 2 拒绝
- ///
- ///
- ///
- ///
- [HttpPost]
- [UnitOfWork]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
-
- public async Task ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
- {
-
- var trialId = agreeReReadingCommand.TrialId;
-
- foreach (var item in agreeReReadingCommand.ConfirmReReadingList)
+ if (task.ReadingTaskState != ReadingTaskState.HaveSigned || (task.TaskState != TaskState.Effect && task.TaskState != TaskState.Freeze))
{
-
- var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id).FirstOrDefaultAsync()).IfNullThrowException();
-
-
- if ((origenalTask.TaskState != TaskState.Effect && origenalTask.TaskState != TaskState.Freeze))
- {
- await _visitTaskReReadingRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new VisitTaskReReading() { RequestReReadingConfirmUserId = _userInfo.Id, RequestReReadingResultEnum = RequestReReadingResult.Invalid });
-
- //---当前申请重阅任务的状态,已被其他任务重阅已影响,不允许对该状态下的任务进行重阅同意与否操作
- return ResponseOutput.Ok(string.Empty, msg: _localizer["VisitTask_ReapplyStatusConflict"]);
- }
-
-
- var criterionConfig = await _trialReadingCriterionRepository.Where(x => x.Id == origenalTask.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.CriterionType, x.IsAdditionalAssessment, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync();
-
- //更新申请信息
- var visitTaskReReadingAppply = await _visitTaskReReadingRepository.FirstOrDefaultAsync(t => t.Id == item.Id);
- visitTaskReReadingAppply.RequestReReadingConfirmUserId = _userInfo.Id;
- visitTaskReReadingAppply.RequestReReadingResultEnum = agreeReReadingCommand.RequestReReadingResultEnum;
- visitTaskReReadingAppply.RequestReReadingRejectReason = agreeReReadingCommand.RequestReReadingRejectReason;
-
-
- Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.TaskAllocationState == TaskAllocationState.Allocated;
-
- //是否是一致性分析任务 正常申请 会影响一致性分析任务
- filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate);
-
- //IR 申请1.1 基线重阅,影响附加评估两个IR所有的任务
- var isIR1Point1AdditionalAssessmentBaseline = false;
-
- //附加评估 IR 和PM 看到的影响列表不一样
-
- //1.1 有附加评估,会影响其他标准的任务
- if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment)
- {
- // PM申请 SPM / CPM审批
- if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (IsSpmOrCPM()))
- {
- filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
- }
- //IR 申请 PM审批
- else
- {
-
- // 1.1 基线任务影响BM任务
- if ((IsPMOrAPm()) && _subjectVisitRepository.Any(t => t.Id == origenalTask.SourceSubjectVisitId && t.IsBaseLine == true))
- {
-
- isIR1Point1AdditionalAssessmentBaseline = true;
-
- }
- // 1.1 非基线任务不影响BM任务
- else
- {
- filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId);
- }
- }
- }
- else
- {
- //默认影响的都是该标准的任务
- filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId);
- }
-
-
- if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree)
- {
- //PM申请 SPM / CPM审批 回退访视,因此这里不生成访视任务 影响多个标准的任务
- if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (IsSpmOrCPM()))
- {
-
- // 不管有序 无序 都会 回退访视
- if (origenalTask.ReadingCategory == ReadingCategory.Visit)
- {
- //执行类似一致性核查回退流程
- await VisitBackAsync(origenalTask.SourceSubjectVisitId);
-
- }
- else
- {
- //---仅允许同意访视类型的任务重阅
- throw new BusinessValidationFailedException(_localizer["VisitTask_ReReadTaskNotApplied"]);
- }
-
- //有序阅片
- if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
- {
-
-
- //访视影响当前以及当前之后的 两个阅片人的
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum);
-
-
- #region 影响的任务
-
-
-
- var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
-
- var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
-
- foreach (var influenceTask in influenceTaskList)
- {
- //处理申请的任务
- if (influenceTask.Id == origenalTask.Id)
- {
- ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
-
- await InfluenceAddtioncalEvaluationCritrionAsync(origenalTask, influenceTaskList.Where(t => t.Id != origenalTask.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => t.SourceSubjectVisitId!.Value).Distinct().ToList());
-
- await PMReReadingConfirmOrBackInfluenceAnalysisAsync(origenalTask.SubjectId);
-
- await SetMedicalReviewInvalidAsync(influenceTaskList);
-
- }
-
-
- if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- influenceTask.TaskState = TaskState.HaveReturned;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- influenceTask.TaskState = TaskState.Adbandon;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
- }
-
-
- }
- #endregion
- }
- //无序阅片 没有 全局 肿瘤学
- else
- {
-
- // 1.当前任务及裁判任务
- // 2.影响所有阅片人的任务
-
- var judegTaskNum = origenalTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge];
-
- filterExpression = filterExpression.And(t => t.VisitTaskNum == origenalTask.VisitTaskNum || t.VisitTaskNum == judegTaskNum);
-
-
- var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
-
- //影像列表为空就为null
- var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
-
- foreach (var influenceTask in influenceTaskList)
- {
- //处理申请的任务
- if (influenceTask.Id == origenalTask.Id)
- {
- ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
-
-
- await PMReReadingConfirmOrBackInfluenceAnalysisAsync(origenalTask.SubjectId);
-
- await SetMedicalReviewInvalidAsync(influenceTaskList);
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- influenceTask.TaskState = TaskState.HaveReturned;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- influenceTask.TaskState = TaskState.Adbandon;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
- }
- }
- }
-
- }
-
-
-
- }
- //IR申请 PM 审批 注意这里有一致性分析的申请同意 不会回退访视,在此要生成影响的访视任务
- else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && (IsPMOrAPm() || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR))
- {
-
-
-
- //有序阅片
- if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
- {
- #region 有序 IR 申请 重阅 影响的其他访视查询
-
-
-
- switch (origenalTask.ReadingCategory)
- {
- case ReadingCategory.Visit:
- //影响后续访视已经读完的,正在读的,未读的不做处理 以及其他类型任务
-
- //申请的是转化的,那么影响列表要排除转化之前的
- if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && origenalTask.BeforeConvertedTaskId != null)
- {
-
-
- filterExpression = filterExpression.And(t => (t.VisitTaskNum > origenalTask.VisitTaskNum &&
- (
- ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == origenalTask.DoctorUserId)
- // 裁判 肿瘤学是另外的医生做
- || t.ReadingCategory == ReadingCategory.Judge
- || t.ReadingCategory == ReadingCategory.Oncology
- )) || t.Id == origenalTask.Id)
- ;
- }
- else if (isIR1Point1AdditionalAssessmentBaseline)
- {
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum &&
- (((
- ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == origenalTask.DoctorUserId)
- // 裁判 肿瘤学是另外的医生做
- || t.ReadingCategory == ReadingCategory.Judge
- || t.ReadingCategory == ReadingCategory.Oncology
- ) && t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId) || (t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB))
- );
- }
- else
- {
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum &&
- (
- ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == origenalTask.DoctorUserId)
- // 裁判 肿瘤学是另外的医生做
- || t.ReadingCategory == ReadingCategory.Judge
- || t.ReadingCategory == ReadingCategory.Oncology
- )
- );
- }
-
-
-
-
-
-
- break;
-
-
- //不影响后续访视: (t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState != ReadingTaskState.WaitReading) ||
- case ReadingCategory.Global:
-
- filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum &&
- ((t.DoctorUserId == origenalTask.DoctorUserId && t.ReadingCategory == ReadingCategory.Global)
- || (t.ReadingCategory == ReadingCategory.Oncology) || (t.ReadingCategory == ReadingCategory.Judge)) || t.Id == origenalTask.Id);
- break;
-
- case ReadingCategory.Oncology:
-
- //仅仅影响自己 后续任务如果是访视任务、全局任务或裁判任务,均不处理
- filterExpression = filterExpression.And(t => t.Id == origenalTask.Id);
- break;
-
- case ReadingCategory.Judge:
-
- //裁判的影响自己 和后续肿瘤学阅片(不是自己做的)
- filterExpression = filterExpression.And(t => t.Id == origenalTask.Id || t.VisitTaskNum > origenalTask.VisitTaskNum && t.ReadingCategory == ReadingCategory.Oncology);
-
- break;
-
-
- default:
- //---不支持重阅的任务类型
- throw new BusinessValidationFailedException(_localizer["VisitTask_UnsupportedTaskType"]);
-
- }
-
- #endregion
-
-
-
- var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).OrderBy(t => t.VisitTaskNum).ToListAsync();
-
- var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
-
-
-
- foreach (var influenceTask in influenceTaskList)
- {
- var beforeTaskState = influenceTask.TaskState;
-
- //已签名的任务 设置转变后的标志
- if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- var isConvertedTask = _visitTaskRepository.Where(t => t.Id == influenceTask.Id).Select(t => t.IsConvertedTask).FirstOrDefault();
-
- if (isConvertedTask)
- {
- influenceTask.IsHistoryConvertedTask = true;
- }
- }
-
-
- //处理申请的任务
- if (influenceTask.Id == origenalTask.Id)
- {
- ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
-
-
- await SetMedicalReviewInvalidAsync(influenceTaskList, false);
-
- await InfluenceAddtioncalEvaluationCritrionAsync(origenalTask, influenceTaskList.Where(t => t.Id != origenalTask.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => t.SourceSubjectVisitId!.Value).Distinct().ToList(), false);
-
- }
-
-
-
- if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- influenceTask.TaskState = TaskState.HaveReturned;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- influenceTask.TaskState = TaskState.Adbandon;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
- }
-
-
- #region 受影响的任务生成
-
- // 影响的任务 仅仅访视类别的才生成 或者就是IR 申请的任务
- if (influenceTask.ReadingCategory == ReadingCategory.Visit || influenceTask.Id == origenalTask.Id)
- {
-
-
- // 影响的其他标准的附加评估的任务不立即生成 比如1.1基线 重阅 PM 同意仅仅生成1.1任务,不生成BM任务
- if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment && influenceTask.TrialReadingCriterionId != origenalTask.TrialReadingCriterionId)
- {
- //BM标准的不生成任务
- continue;
- }
-
-
- // i1.1标准 当前任务是转变任务,并且影响列表里有转变之前的任务 那么该访视任务就不生成
- if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1)
- {
- //申请的任务是冻结的任务(该任务发生转变) 影响自己 以及转变后的 以及后续任务 但是生成的时候,仅仅生成转变之前的
- //申请的是转变之后的任务 (转变生成的任务) 影响自己以及后续任务 生成转变后的任务
- if (influenceTask.BeforeConvertedTaskId != null && influenceTaskList.Any(t => t.Id == influenceTask.BeforeConvertedTaskId))
- {
- //有转化的任务 和转化之前的任务时,转化后的任务时不生成的
- continue;
-
- }
-
-
- }
-
-
- await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
- {
- TrialId = trialId,
-
- ReadingCategory = GenerateTaskCategory.ReReading,
-
- ReReadingTask = influenceTask,
-
- //同步才可以
- Action = (newTask) =>
- {
- //申请表 设置新任务Id
- visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
-
- //生成的任务分配给原始医生
- newTask.DoctorUserId = origenalTask.DoctorUserId;
- newTask.TaskAllocationState = TaskAllocationState.Allocated;
- newTask.AllocateTime = DateTime.Now;
- newTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget);
-
- //拷贝原始表单
- if (visitTaskReReadingAppply.IsCopyOrigenalForms && influenceTask.Id == origenalTask.Id)
- {
- if (origenalTask.ReadingCategory == ReadingCategory.Visit)
- {
- CopyForms(newTask, origenalTask);
-
- }
-
- }
-
- //拷贝后续表单
- if (visitTaskReReadingAppply.IsCopyFollowForms && origenalTask.VisitTaskNum != influenceTask.VisitTaskNum)
- {
- if (origenalTask.ReadingCategory == ReadingCategory.Visit)
- {
- CopyForms(newTask, origenalTask);
- }
-
-
- }
-
- }
- });
-
-
-
- #endregion
-
-
- }
-
- }
-
-
-
- }
- //无序阅片 IR只会申请访视类型和裁判类型的任务 注意这里有一致性分析的申请同意
- else
- {
-
-
- //1.当前任务及裁判任务
- //2.影响当前阅片人的任务
- filterExpression = filterExpression.And(t => t.Id == origenalTask.Id || t.Id == origenalTask.JudgeVisitTaskId);
-
-
- var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
-
- var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
-
- foreach (var influenceTask in influenceTaskList)
- {
- //申请原任务处理
- if (influenceTask.Id == origenalTask.Id)
- {
- ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
-
- await SetMedicalReviewInvalidAsync(influenceTaskList, false);
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- influenceTask.TaskState = TaskState.HaveReturned;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- influenceTask.TaskState = TaskState.Adbandon;
-
- trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
- }
- }
-
- #region 受影响任务的生成
-
- if (influenceTask.ReadingCategory == ReadingCategory.Visit || influenceTask.Id == origenalTask.Id)
- {
- await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
- {
- TrialId = trialId,
-
- ReadingCategory = GenerateTaskCategory.ReReading,
-
- ReReadingTask = origenalTask,
-
- //同步才可以
- Action = (newTask) =>
- {
- //申请表 设置新任务Id
- visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
-
- ////生成的任务分配给原始医生
- newTask.DoctorUserId = origenalTask.DoctorUserId;
- newTask.TaskAllocationState = TaskAllocationState.Allocated;
- newTask.AllocateTime = DateTime.Now;
- newTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget);
-
-
- //裁判任务 需要进行特殊处理 在重阅逻辑里面处理
-
-
- if (visitTaskReReadingAppply.IsCopyOrigenalForms && influenceTask.Id == origenalTask.Id)
- {
- if (origenalTask.ReadingCategory == ReadingCategory.Visit)
- {
- CopyForms(newTask, origenalTask);
-
- }
-
- }
-
- //拷贝后续表单
- if (visitTaskReReadingAppply.IsCopyFollowForms && origenalTask.VisitTaskNum != influenceTask.VisitTaskNum)
- {
- if (origenalTask.ReadingCategory == ReadingCategory.Visit)
- {
- CopyForms(newTask, origenalTask);
-
- }
- }
-
-
- }
- });
-
- }
- #endregion
-
- }
-
- }
-
- }
- else
- {
- //---不符合 PM申请 SPM / CPM审批 | IR申请 PM 审批
- throw new BusinessValidationFailedException(_localizer["VisitTask_ReReadTaskAlreadyAffected"]);
- }
-
- }
- else if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Reject)
- {
-
- if (origenalTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || origenalTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
- {
- await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == origenalTask.Id, u => new VisitTask()
- {
- ReReadingApplyState = ReReadingApplyState.Reject
- });
- }
- else
- {
- //---当前重阅任务状态不为已申请状态,不允许进行处理,请刷新页面
- throw new BusinessValidationFailedException(_localizer["VisitTask_InvalidReapplyStatus"]);
- }
-
- }
-
-
-
-
+ //---未阅片完成,或者未生效的任务不允许申请重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_BackendData"]);
+ }
+
+ if (task.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || task.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed || task.ReReadingApplyState == ReReadingApplyState.Agree)
+ {
+ //---重阅已申请,或者重阅已同意状态下不允许申请重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_UnreadTask"]);
}
-
- await _visitTaskRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok();
- }
-
- private void CopyForms(VisitTask newTask, VisitTask origenalTask)
- {
-
- //自定义
- var readingCustomTagList = _readingCustomTagRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
-
- foreach (var item in readingCustomTagList)
- {
- item.Id = Guid.Empty;
- item.VisitTaskId = newTask.Id;
- }
-
- _ = _readingCustomTagRepository.AddRangeAsync(readingCustomTagList).Result;
-
-
- var readingTaskQuestionMarkList = _readingTaskQuestionMarkRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
-
- foreach (var item in readingTaskQuestionMarkList)
- {
- item.Id = Guid.Empty;
- item.VisitTaskId = newTask.Id;
- }
-
- _ = _readingTaskQuestionMarkRepository.AddRangeAsync(readingTaskQuestionMarkList).Result;
-
- var readingTaskQuestionAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
-
- foreach (var item in readingTaskQuestionAnswerList)
- {
- item.Id = Guid.Empty;
- item.VisitTaskId = newTask.Id;
- }
- _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(readingTaskQuestionAnswerList).Result;
-
-
-
- //ReadingTableAnswerRowInfo ReadingTableQuestionAnswer 一起加
- var readingTableAnswerRowInfoList = _readingTableAnswerRowInfoRepository.Where(t => t.VisitTaskId == origenalTask.Id).Include(t => t.LesionAnswerList).ToList();
-
- foreach (var item in readingTableAnswerRowInfoList)
- {
-
- var originalVisitTaskId = item.VisitTaskId;
- var originalFristAddTaskId = item.FristAddTaskId;
-
- item.Id = NewId.NextSequentialGuid();
- item.VisitTaskId = newTask.Id;
-
- //默认值是当前任务添加的
- item.FristAddTaskId = originalVisitTaskId == originalFristAddTaskId ? newTask.Id : item.FristAddTaskId;
-
-
- foreach (var item2 in item.LesionAnswerList)
- {
- item2.Id = Guid.Empty;
- item2.RowId = item.Id;
- item2.VisitTaskId = newTask.Id;
- }
- }
-
- _ = _readingTableAnswerRowInfoRepository.AddRangeAsync(readingTableAnswerRowInfoList).Result;
-
-
-
-
-
- }
-
-
- ///
- /// PM 设置任务 退回
- ///
- ///
- [HttpPut("{trialId:guid}/{taskId:guid}")]
- [UnitOfWork]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
-
- public async Task PMSetTaskBack(Guid trialId, Guid taskId)
- {
-
- //var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.IsReadingTaskViewInOrder, t.ReadingType }).FirstOrDefaultAsync()).IfNullThrowException();
-
-
- var task = (await _visitTaskRepository.Where(t => t.Id == taskId).FirstOrDefaultAsync()).IfNullThrowException();
-
- var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == task.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.CriterionType, x.IsAutoCreate, x.IsAdditionalAssessment, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
-
- if (criterionConfig.IsAutoCreate == false)
- {
- //---手动生成任务的不允许在此入口影像退回
- return ResponseOutput.NotOk(_localizer["VisitTask_NoImageReturn"]);
- }
-
- if (task.TaskState != TaskState.Effect || task.ReadingCategory != ReadingCategory.Visit || task.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- //---仅仅允许针对生效、未完成的访视任务进行退回操作,请刷新页面数据
- return ResponseOutput.NotOk(_localizer["VisitTask_NonEffectiveTaskCannotBeReturned"]);
- }
-
-
- if (await _subjectVisitRepository.AnyAsync(t => t.Id == task.SourceSubjectVisitId && t.CheckState != CheckStateEnum.CVPassed))
- {
- //---当前访视已回退到影像上传,不允许继续回退!
- return ResponseOutput.NotOk(_localizer["VisitTask_NoFurtherReturn"]);
- }
-
-
- if (task.IsAnalysisCreate)
- {
- //---一致性分析的任务,不允许设置退回
- return ResponseOutput.NotOk(_localizer["VisitTask_ConsistencyTaskCannotBeReturned"]);
- }
-
- Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == task.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.TaskAllocationState == TaskAllocationState.Allocated;
-
-
- #region 退回到访视 不区分标准
- //if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment)
- //{
- // //影像退回,必定影响两个标准的任务
- // filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == task.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
-
-
- //}
- //else
- //{
- // //默认影响的都是该标准的任务
- // filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == task.TrialReadingCriterionId);
- //}
- #endregion
-
-
- //PM 才允许操作
if (IsPMOrAPm())
{
+ if (criterionConfig.IsAutoCreate == false)
+ {
+ //---手动生成任务的不允许PM 申请影像重阅
+ return ResponseOutput.NotOk(_localizer["VisitTask_NoPMRecheck"]);
+ }
- #region 有序 无序公用流程
+ if (task.IsAnalysisCreate)
+ {
+ //---PM 不允许对一致性分析任务进行申请重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_Reapply"]);
+ }
+
+ if (task.ReadingCategory != ReadingCategory.Visit)
+ {
+ //---PM 仅仅允许对访视类型的任务申请重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_ConsistencyAnalysis"]);
+ }
- //执行类似一致性核查回退流程 回退访视到影像上传流程
- await VisitBackAsync(task.SourceSubjectVisitId);
-
- #endregion
-
-
-
- //有序
+ // 有序 一个受试者访视重阅未处理完,不能申请其他的
if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
{
-
- //Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && t.TaskAllocationState == TaskAllocationState.Allocated;
-
- filterExpression = filterExpression.And(t => t.IsAnalysisCreate == false);
-
-
-
- //另一个阅片人的任务根据任务进度自动进入PM退回或PM申请重阅
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= task.VisitTaskNum);
-
-
- var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
-
-
-
- #region 方式二
-
-
- //pm退回的时候,影响的任务里不一定有该任务id 双重 分配了一个人,退回的时候,选择的是未分配的
-
- //var origenalTask = influenceTaskList.Where(t => t.Id == task.Id).FirstOrDefault();
-
- var origenalTask = await _visitTaskRepository.FindAsync(task.Id);
-
-
- foreach (var influenceTask in influenceTaskList)
+ if (await _visitTaskReReadingRepository.AnyAsync(t => t.OriginalReReadingTask.TrialId == task.TrialId && t.OriginalReReadingTask.SubjectId == task.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect
+ && t.OriginalReReadingTask.TrialReadingCriterionId == task.TrialReadingCriterionId
+ && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default))
{
-
- //已签名的任务 设置转变后的标志
- if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- var isConvertedTask = _visitTaskRepository.Where(t => t.Id == influenceTask.Id).Select(t => t.IsConvertedTask).FirstOrDefault();
-
- if (isConvertedTask)
- {
- influenceTask.IsHistoryConvertedTask = true;
- }
- }
-
- //同意的访视 因为要记录具体的操作,所以废弃
- if (influenceTask.Id == task.Id)
- {
-
- await InfluenceAddtioncalEvaluationCritrionAsync(task, influenceTaskList.Where(t => t.Id != task.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => t.SourceSubjectVisitId!.Value).Distinct().ToList());
-
- await PMReReadingConfirmOrBackInfluenceAnalysisAsync(influenceTask.SubjectId);
-
- await SetMedicalReviewInvalidAsync(influenceTaskList);
-
-
- influenceTask.IsPMSetBack = true;
- }
-
- if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- influenceTask.TaskState = TaskState.HaveReturned;
- origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- influenceTask.TaskState = TaskState.Adbandon;
- origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
- }
-
+ //---当前为有序阅片,该受试者已有访视已申请重阅还未处理(项目组申请),暂不能继续申请重阅
+ return ResponseOutput.NotOk(_localizer["VisitTask_VisitTypeRestriction"]);
}
-
- #endregion
-
-
-
}
- else
- {
- //无序 无序阅片没有 全局 肿瘤学
- // 申请该访视的任务 申请人失效 另外一个人重阅重置或者失效
+ task.ReReadingApplyState = ReReadingApplyState.TrialGroupHaveApplyed;
- var currentVisitList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.ReadingCategory == ReadingCategory.Visit && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.VisitTaskNum == task.VisitTaskNum, true).ToListAsync();
-
- await SetMedicalReviewInvalidAsync(currentVisitList);
-
- //var origenalTask = currentVisitList.Where(t => t.Id == task.Id).First();
-
- var origenalTask = await _visitTaskRepository.FindAsync(task.Id);
-
- foreach (var influenceTask in currentVisitList)
- {
- if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
- {
- //另外阅片人完成阅片了 就设置为重阅重置
- influenceTask.TaskState = TaskState.HaveReturned;
-
- origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
- }
- else
- {
- influenceTask.TaskState = TaskState.Adbandon;
-
- origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
- }
-
- }
-
- }
}
- else
+ if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer)
{
- //---仅PM 可以进行回退操作
- return ResponseOutput.NotOk(_localizer["VisitTask_PMOnlyAllowedForReturn"]);
- }
+ task.ReReadingApplyState = ReReadingApplyState.DocotorHaveApplyed;
+ //在PM 的申请重阅的影响列表里也不能申请重阅
+
+ var pmApply = await _visitTaskReReadingRepository.Where(t => t.OriginalReReadingTask.TrialId == task.TrialId && t.OriginalReReadingTask.SubjectId == task.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect && t.OriginalReReadingTask.ReadingCategory == ReadingCategory.Visit
+ && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default).Include(t => t.OriginalReReadingTask).FirstOrDefaultAsync();
-
-
- await _visitTaskRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok();
- }
-
-
- ///
- /// 基线退回 影响附加评估标准 是否参与评估
- ///
- ///
- private async Task InfluenceAddtioncalEvaluationCritrionAsync(VisitTask task, List otherVisitIdList, bool isImageBack = true)
- {
-
- var criterion = await _trialReadingCriterionRepository.FindAsync(task.TrialReadingCriterionId);
-
- if (criterion.CriterionType == CriterionType.RECIST1Point1)
- {
- //影像回退了|| IR 申请及基线重阅
- if (_subjectVisitRepository.Any(t => t.Id == task.SourceSubjectVisitId && t.IsBaseLine))
+ // 有序
+ if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
{
- await _subjectCriteriaEvaluationRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.IsAutoCreate == false && t.SubjectId == task.SubjectId, u => new SubjectCriteriaEvaluation()
+ // 针对同一个subject 不同阅片人 针对同一个访视申请重阅,是允许的,所以同一阅片人,针对同一suject 有访视申请重阅还未处理,不允许申请重阅
+ if (await _visitTaskReReadingRepository.AnyAsync(t => t.OriginalReReadingTask.TrialId == task.TrialId && t.OriginalReReadingTask.SubjectId == task.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect
+ && t.OriginalReReadingTask.TrialReadingCriterionId == task.TrialReadingCriterionId && t.OriginalReReadingTask.DoctorUserId == task.DoctorUserId
+ && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.RequestReReadingType == RequestReReadingType.DocotorApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default))
{
- IsJoinEvaluation = false
- });
-
- //删除筛选的访视数据
- await _subjectCriteriaEvaluationVisitFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectId == task.SubjectId);
-
- //删除筛选的序列数据
- await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId);
- }
- else if (isImageBack)
- {
- //当前访视筛选状态重置,任务生成状态重置
- if (task.SourceSubjectVisitId != null)
- {
- await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && t.SubjectVisitId == task.SourceSubjectVisitId,
- t => new SubjectCriteriaEvaluationVisitFilter()
- {
- ImageFilterState = ImageFilterState.None,
- ImageDeterminationResultState = ImageDeterminationResultState.None,
- IsGeneratedTask = false
- });
-
- //删除序列数据
- await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && t.SubjectVisitId == task.SourceSubjectVisitId);
+ //---当前为有序阅片,该受试者已有访视已申请重阅还未处理,暂不能继续申请重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_SequentialReading"]);
}
- //BM后续访视 ,筛选状态不变,任务生成状态重置(实际该访视任务状态 可能是重阅重置了或者失效了,需要后续生成,或者取消分配了,需要后续重新分配)
- await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && otherVisitIdList.Contains(t.SubjectVisitId),
- t => new SubjectCriteriaEvaluationVisitFilter()
+
+ if (pmApply != null)
+ {
+ var originalTask = pmApply.OriginalReReadingTask;
+
+ //PM 有序影响列表
+ if (await _visitTaskRepository.Where(t => t.TrialId == originalTask.TrialId && t.SubjectId == originalTask.SubjectId && t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated && t.IsAnalysisCreate == false && t.TrialReadingCriterionId == originalTask.TrialReadingCriterionId && t.VisitTaskNum >= originalTask.VisitTaskNum)
+ .AnyAsync(t => t.VisitTaskNum == task.VisitTaskNum))
{
- IsGeneratedTask = false
- });
+ //---当前为有序阅片,影像存在问题,项目组已申请回退,暂不能申请重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_ImageProblem"]);
+ }
+
+ }
+
+
+
+ Expression> filterExpression = t => t.TrialId == task.TrialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.TrialReadingCriterionId == task.TrialReadingCriterionId
+ && t.DoctorUserId == task.DoctorUserId && t.IsAnalysisCreate == false && t.VisitTaskNum > task.VisitTaskNum;
+
+
+
+ if (task.ReadingCategory == ReadingCategory.Global && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Global)))
+ {
+ //---有序阅片,只允许申请该受试者阅片人最后一次完成全局任务重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_LastReading"]);
+ }
+
+ if (task.ReadingCategory == ReadingCategory.Oncology && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Oncology && t.ReadingTaskState == ReadingTaskState.HaveSigned)))
+ {
+ //---有序阅片,只允许申请该受试者阅片人最后一次完成肿瘤学任务重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_LastOncologistRecheck"]);
+ }
+
+ if (task.ReadingCategory == ReadingCategory.Judge && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Judge && t.ReadingTaskState == ReadingTaskState.HaveSigned)))
+ {
+ //---有序阅片,只允许申请该受试者阅片人最后一次完成裁判的任务重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_LastAdjudicatorRecheck"]);
+ }
+
}
else
{
- //IR 端 非基线申请重阅 不影响
+
+ if (pmApply != null)
+ {
+ var originalTask = pmApply.OriginalReReadingTask;
+
+ //PM 无序影响列表
+ if (await _visitTaskRepository.Where(t => t.TrialId == originalTask.TrialId && t.SubjectId == originalTask.SubjectId && t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated && t.IsAnalysisCreate == false && t.TrialReadingCriterionId == originalTask.TrialReadingCriterionId)
+ .Where(t => t.Id == originalTask.Id || t.Id == originalTask.JudgeVisitTaskId)
+ .AnyAsync(t => t.VisitTaskNum == task.VisitTaskNum))
+ {
+ //---当前为无序阅片,影像存在问题,项目组已申请回退,暂不能申请重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_RandomInvalidRereading"]);
+ }
+
+ }
+
+ //也要支持裁判重阅240701
+
+ if (task.ReadingCategory != ReadingCategory.Visit && task.ReadingCategory != ReadingCategory.Judge)
+ {
+ //---无序阅片,仅仅允许IR 申请 访视、裁判类型类别的任务进行重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_IRGlobalRecheck"]);
+ }
}
+
}
-
-
- }
-
- //包括临床数据签名状态
- private async Task VisitBackAsync(Guid? subjectVisitId)
- {
- var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException();
-
-
- //需要重新产生任务
- sv.IsVisitTaskGenerated = false;
- sv.IsPMBackOrReReading = true;
-
- sv.AuditState = AuditStateEnum.None;
- sv.SubmitState = SubmitStateEnum.ToSubmit;
- sv.ReadingStatus = ReadingStatusEnum.ImageNotSubmit;
-
- //回退后,回退状态恢复
- sv.RequestBackState = RequestBackStateEnum.NotRequest;
- sv.IsCheckBack = false;
- sv.CheckBackTime = null;
- sv.CheckState = CheckStateEnum.None;
- sv.CheckChallengeState = CheckChanllengeTypeEnum.None;
-
- sv.SVENDTC = null;
- sv.SVSTDTC = null;
-
- sv.PreliminaryAuditTime = null;
- sv.SubmitTime = null;
- sv.ReviewAuditTime = null;
- sv.CurrentActionUserExpireTime = null;
-
-
- sv.IsTake = false;
- sv.CurrentActionUserId = null;
- sv.PreliminaryAuditUserId = null;
- sv.ReviewAuditUserId = null;
-
-
- if (sv.IsBaseLine)
+ //AIR 不加验证
+ if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR)
{
- await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && (t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.Subject || t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit), c => new ReadingClinicalData() { IsSign = false, ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded });
-
+ task.ReReadingApplyState = ReReadingApplyState.DocotorHaveApplyed;
}
- else
+
+
+
+ var rootReReadingTaskId = _visitTaskReReadingRepository.Where(t => t.NewReReadingTaskId == task.Id).Select(u => u.RootReReadingTaskId).FirstOrDefault();
+
+ //添加申请记录
+ var visitTaskReReading = await _visitTaskReReadingRepository.AddAsync(new VisitTaskReReading()
{
- await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit, c => new ReadingClinicalData()
- {
- IsSign = false,
- ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded,
- IsBlind = null,
- IsComplete = null
- });
+ TrialId = applyReReadingCommand.TrialId,
+ RootReReadingTaskId = rootReReadingTaskId == Guid.Empty ? task.Id : rootReReadingTaskId,
+ OriginalReReadingTaskId = task.Id,
+ RequestReReadingTime = DateTime.Now,
+ RequestReReadingUserId = _userInfo.Id,
+ IsCopyOrigenalForms = applyReReadingCommand.IsCopyOrigenalForms,
+ IsCopyFollowForms = applyReReadingCommand.IsCopyFollowForms,
+ RequestReReadingReason = applyReReadingCommand.RequestReReadingReason,
+ RequestReReadingType = applyReReadingCommand.RequestReReadingType,
+
+ });
+ }
+
+
+ await _visitTaskRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok();
+ }
+
+
+ ///
+ /// 重阅原任务跟踪处理
+ ///
+ ///
+ ///
+ ///
+ private void ReReadingTaskTrackingDeal(VisitTask origenalTask, ConfirmReReadingCommand agreeReReadingCommand)
+ {
+ if (origenalTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || origenalTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
+ {
+ origenalTask.ReReadingApplyState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? ReReadingApplyState.Agree : ReReadingApplyState.Reject;
+ origenalTask.TaskState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? TaskState.HaveReturned : origenalTask.TaskState;
+ }
+ else
+ {
+ //---当前重阅任务状态不为已申请状态,不允许进行处理,请刷新页面
+ throw new BusinessValidationFailedException(_localizer["VisitTask_InvalidReapplyStatus"]);
+ }
+
+ }
+
+ private async Task SetMedicalReviewInvalidAsync(List influenceTaskList, bool isPMApply = true)
+ {
+ //将医学审核设置为失效
+ var taskIdList = influenceTaskList.Select(t => t.Id).ToList();
+
+ //PM 申请 医学审核任务状态为待审核、审核中的,设置为失效。
+
+ //IR 申请 当前任务进入医学审核,医学审核任务未签名且结论中是否有问题项,答案为否的,设置为失效
+
+ if (isPMApply)
+ {
+ await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.VisitTaskId) && t.AuditState != MedicalReviewAuditState.HaveSigned, u => new TaskMedicalReview() { IsInvalid = true });
+
+ }
+ else
+ {
+
+ await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.VisitTaskId) && t.IsHaveQuestion == false && t.AuditState != MedicalReviewAuditState.HaveSigned, u => new TaskMedicalReview() { IsInvalid = true });
+ }
+ }
+
+ ///
+ /// PM 申请重阅 被同意 或者 PM 直接退回的时候影响
+ ///
+ ///
+ ///
+ private async Task PMReReadingConfirmOrBackInfluenceAnalysisAsync(Guid subjectId)
+ {
+ if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.SubjectId == subjectId))
+ {
+ await _subjectRepository.UpdatePartialFromQueryAsync(t => t.Id == subjectId, u => new Subject() { IsReReadingOrBackInfluenceAnalysis = true });
+
+ }
+
+ }
+
+ public DateTime GetSuggessFinishTime(bool isInOrder, UrgentType urgentType)
+ {
+
+ var datetime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 22, 0, 0).AddDays(7);
+
+ return datetime;
+ }
+
+ ///
+ /// 确认重阅与否 1同意 2 拒绝
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ [UnitOfWork]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+
+ public async Task ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
+ {
+
+ var trialId = agreeReReadingCommand.TrialId;
+
+ foreach (var item in agreeReReadingCommand.ConfirmReReadingList)
+ {
+
+ var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id).FirstOrDefaultAsync()).IfNullThrowException();
+
+
+ if ((origenalTask.TaskState != TaskState.Effect && origenalTask.TaskState != TaskState.Freeze))
+ {
+ await _visitTaskReReadingRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new VisitTaskReReading() { RequestReReadingConfirmUserId = _userInfo.Id, RequestReReadingResultEnum = RequestReReadingResult.Invalid });
+
+ //---当前申请重阅任务的状态,已被其他任务重阅已影响,不允许对该状态下的任务进行重阅同意与否操作
+ return ResponseOutput.Ok(string.Empty, msg: _localizer["VisitTask_ReapplyStatusConflict"]);
}
+ var criterionConfig = await _trialReadingCriterionRepository.Where(x => x.Id == origenalTask.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.CriterionType, x.IsAdditionalAssessment, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync();
- //await _repository.AddAsync(new CheckChallengeDialog() { SubjectVisitId = subjectVisitId, TalkContent = "PM/APM同意一致性核查回退。", UserTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt });
-
- await _trialQCQuestionAnswerRepository.BatchDeleteNoTrackingAsync(t => t.SubjectVisitId == subjectVisitId);
- await _dicomInstanceRepository.BatchDeleteNoTrackingAsync(t => t.DicomSerie.IsDeleted);
- await _dicomSeriesRepository.BatchDeleteNoTrackingAsync(t => t.IsDeleted);
-
- var success = await _subjectVisitRepository.SaveChangesAsync();
-
- }
+ //更新申请信息
+ var visitTaskReReadingAppply = await _visitTaskReReadingRepository.FirstOrDefaultAsync(t => t.Id == item.Id);
+ visitTaskReReadingAppply.RequestReReadingConfirmUserId = _userInfo.Id;
+ visitTaskReReadingAppply.RequestReReadingResultEnum = agreeReReadingCommand.RequestReReadingResultEnum;
+ visitTaskReReadingAppply.RequestReReadingRejectReason = agreeReReadingCommand.RequestReReadingRejectReason;
- private bool IsPMOrAPm()
- {
- return _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM;
- }
+ Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.TaskAllocationState == TaskAllocationState.Allocated;
- private bool IsSpmOrCPM()
- {
- return _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM;
- }
+ //是否是一致性分析任务 正常申请 会影响一致性分析任务
+ filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate);
- ///
- /// 影响提示列表 重阅仅仅针对已完成的任务申请 退回针对的是未完成的(退回仅仅针对是访视类型的)
- ///
- ///
- /// 重阅还是直接回退
- /// 申请记录的Id
- ///
- [HttpGet("{taskId:guid}/{isReReading:bool}")]
- public async Task<(List, object)> GetReReadingOrBackInfluenceTaskList(Guid taskId, bool isReReading, Guid? applyId)
- {
- var isIRAppyTaskInfluenced = false;
-
- var filterObj = (await _visitTaskRepository.FirstOrDefaultNoTrackingAsync(t => t.Id == taskId)).IfNullThrowException();
- var trialId = filterObj.TrialId;
-
- var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == filterObj.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.CriterionType, x.IsAdditionalAssessment, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
-
- Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.TaskAllocationState == TaskAllocationState.Allocated;
-
- //是否是一致性分析任务 (一致性分析的任务 不会产生裁判 肿瘤学 仅仅有生成的访视和全局)
-
- filterExpression = filterExpression.And(t => t.IsAnalysisCreate == filterObj.IsAnalysisCreate);
-
- //IR 申请1.1 基线重阅,影响附加评估所有的任务
+ //IR 申请1.1 基线重阅,影响附加评估两个IR所有的任务
var isIR1Point1AdditionalAssessmentBaseline = false;
//附加评估 IR 和PM 看到的影响列表不一样
+
+ //1.1 有附加评估,会影响其他标准的任务
if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment)
{
-
- // IR 申请 PM 同意
- if (((IsPMOrAPm() && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer))
- || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null)))
+ // PM申请 SPM / CPM审批
+ if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (IsSpmOrCPM()))
+ {
+ filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
+ }
+ //IR 申请 PM审批
+ else
{
// 1.1 基线任务影响BM任务
- if (IsPMOrAPm() && _subjectVisitRepository.Any(t => t.Id == filterObj.SourceSubjectVisitId && t.IsBaseLine == true))
+ if ((IsPMOrAPm()) && _subjectVisitRepository.Any(t => t.Id == origenalTask.SourceSubjectVisitId && t.IsBaseLine == true))
{
isIR1Point1AdditionalAssessmentBaseline = true;
- //filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
-
}
// 1.1 非基线任务不影响BM任务
else
{
- filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId);
+ filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId);
}
-
- }
- //(1、PM回退,PM申请重阅,SPM同意回退)
- else
- {
- filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
-
}
}
else
{
//默认影响的都是该标准的任务
- filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId);
+ filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId);
}
-
- //重阅影响
- if (isReReading)
+ if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree)
{
-
-
-
- //IR 申请 PM 同意 仅仅影响自己
-
- if ((IsPMOrAPm() && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer))
- || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null))
+ //PM申请 SPM / CPM审批 回退访视,因此这里不生成访视任务 影响多个标准的任务
+ if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (IsSpmOrCPM()))
{
- //当前任务及其之后的所有访视任务、全局任务、裁判任务、肿瘤学阅片任务
+ // 不管有序 无序 都会 回退访视
+ if (origenalTask.ReadingCategory == ReadingCategory.Visit)
+ {
+ //执行类似一致性核查回退流程
+ await VisitBackAsync(origenalTask.SourceSubjectVisitId);
- //有序
+ }
+ else
+ {
+ //---仅允许同意访视类型的任务重阅
+ throw new BusinessValidationFailedException(_localizer["VisitTask_ReReadTaskNotApplied"]);
+ }
+
+ //有序阅片
if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
{
- switch (filterObj.ReadingCategory)
+
+ //访视影响当前以及当前之后的 两个阅片人的
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum);
+
+
+ #region 影响的任务
+
+
+
+ var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
+
+ var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
+
+ foreach (var influenceTask in influenceTaskList)
{
- case ReadingCategory.Visit:
- //影响当前医生 以及当前医生之后的 1、访视任务 已经读完的
- //2、后续任务如果是全局、肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效;
- //3、当前任务、后续访视任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效
+ //处理申请的任务
+ if (influenceTask.Id == origenalTask.Id)
+ {
+ ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
- //申请的是转化的,那么影响列表要排除转化之前的
- if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && filterObj.BeforeConvertedTaskId != null)
+ await InfluenceAddtioncalEvaluationCritrionAsync(origenalTask, influenceTaskList.Where(t => t.Id != origenalTask.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => t.SourceSubjectVisitId!.Value).Distinct().ToList());
+
+ await PMReReadingConfirmOrBackInfluenceAnalysisAsync(origenalTask.SubjectId);
+
+ await SetMedicalReviewInvalidAsync(influenceTaskList);
+
+ }
+
+
+ if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ influenceTask.TaskState = TaskState.HaveReturned;
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
+ }
+ else
+ {
+ influenceTask.TaskState = TaskState.Adbandon;
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
+ }
+
+
+ }
+ #endregion
+ }
+ //无序阅片 没有 全局 肿瘤学
+ else
+ {
+
+ // 1.当前任务及裁判任务
+ // 2.影响所有阅片人的任务
+
+ var judegTaskNum = origenalTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge];
+
+ filterExpression = filterExpression.And(t => t.VisitTaskNum == origenalTask.VisitTaskNum || t.VisitTaskNum == judegTaskNum);
+
+
+ var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
+
+ //影像列表为空就为null
+ var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
+
+ foreach (var influenceTask in influenceTaskList)
+ {
+ //处理申请的任务
+ if (influenceTask.Id == origenalTask.Id)
+ {
+ ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
+
+
+ await PMReReadingConfirmOrBackInfluenceAnalysisAsync(origenalTask.SubjectId);
+
+ await SetMedicalReviewInvalidAsync(influenceTaskList);
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
+ }
+ else
+ {
+ if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
+ influenceTask.TaskState = TaskState.HaveReturned;
-
- filterExpression = filterExpression.And(t => (t.VisitTaskNum > filterObj.VisitTaskNum &&
- (
- ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == filterObj.DoctorUserId)
- // 裁判 肿瘤学是另外的医生做
- || t.ReadingCategory == ReadingCategory.Judge
- || t.ReadingCategory == ReadingCategory.Oncology
- )) || t.Id == filterObj.Id)
- ;
- }
- // IR 申请1.1 基线重阅,影响附加评估所有的任务
- else if (isIR1Point1AdditionalAssessmentBaseline)
- {
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum &&
- (((
- ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == filterObj.DoctorUserId)
- // 裁判 肿瘤学是另外的医生做
- || t.ReadingCategory == ReadingCategory.Judge
- || t.ReadingCategory == ReadingCategory.Oncology
- ) && t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId) || (t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB))
- );
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
}
else
{
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum &&
+ influenceTask.TaskState = TaskState.Adbandon;
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
+ }
+ }
+ }
+
+ }
+
+
+
+ }
+ //IR申请 PM 审批 注意这里有一致性分析的申请同意 不会回退访视,在此要生成影响的访视任务
+ else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && (IsPMOrAPm() || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR))
+ {
+
+
+
+ //有序阅片
+ if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ {
+ #region 有序 IR 申请 重阅 影响的其他访视查询
+
+
+
+ switch (origenalTask.ReadingCategory)
+ {
+ case ReadingCategory.Visit:
+ //影响后续访视已经读完的,正在读的,未读的不做处理 以及其他类型任务
+
+ //申请的是转化的,那么影响列表要排除转化之前的
+ if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && origenalTask.BeforeConvertedTaskId != null)
+ {
+
+
+ filterExpression = filterExpression.And(t => (t.VisitTaskNum > origenalTask.VisitTaskNum &&
+ (
+ ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == origenalTask.DoctorUserId)
+ // 裁判 肿瘤学是另外的医生做
+ || t.ReadingCategory == ReadingCategory.Judge
+ || t.ReadingCategory == ReadingCategory.Oncology
+ )) || t.Id == origenalTask.Id)
+ ;
+ }
+ else if (isIR1Point1AdditionalAssessmentBaseline)
+ {
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum &&
+ (((
+ ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == origenalTask.DoctorUserId)
+ // 裁判 肿瘤学是另外的医生做
+ || t.ReadingCategory == ReadingCategory.Judge
+ || t.ReadingCategory == ReadingCategory.Oncology
+ ) && t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId) || (t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB))
+ );
+ }
+ else
+ {
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum &&
(
- ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == filterObj.DoctorUserId)
+ ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == origenalTask.DoctorUserId)
// 裁判 肿瘤学是另外的医生做
|| t.ReadingCategory == ReadingCategory.Judge
|| t.ReadingCategory == ReadingCategory.Oncology
@@ -2696,43 +1841,28 @@ namespace IRaCIS.Core.Application.Service.Allocation
+
break;
+
+ //不影响后续访视: (t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState != ReadingTaskState.WaitReading) ||
case ReadingCategory.Global:
- // 1、后续任务如果是访视任务,均不处理;
- //2、后续任务如果是全局、状态为阅片完成则标记为重阅重置,若阅片中或待阅片则不处理;
- //3、当前任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效
- //4、后续任务为肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效;
-
- //filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum &&
- //((t.DoctorUserId == filterObj.DoctorUserId && ((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned) || t.ReadingCategory == ReadingCategory.Global)) || (t.ReadingCategory == ReadingCategory.Oncology) || (t.ReadingCategory == ReadingCategory.Judge)));
-
-
- filterExpression = filterExpression.And(t => t.VisitTaskNum > filterObj.VisitTaskNum &&
- (
- (t.DoctorUserId == filterObj.DoctorUserId && t.ReadingCategory == ReadingCategory.Global)
- || (t.ReadingCategory == ReadingCategory.Oncology)
- || (t.ReadingCategory == ReadingCategory.Judge)
- ) || t.Id == filterObj.Id);
-
+ filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum &&
+ ((t.DoctorUserId == origenalTask.DoctorUserId && t.ReadingCategory == ReadingCategory.Global)
+ || (t.ReadingCategory == ReadingCategory.Oncology) || (t.ReadingCategory == ReadingCategory.Judge)) || t.Id == origenalTask.Id);
break;
- //1、后续任务如果是访视任务、全局任务或裁判任务,均不处理;
case ReadingCategory.Oncology:
- //仅仅影响自己
- filterExpression = filterExpression.And(t => t.Id == filterObj.Id);
+ //仅仅影响自己 后续任务如果是访视任务、全局任务或裁判任务,均不处理
+ filterExpression = filterExpression.And(t => t.Id == origenalTask.Id);
break;
- //(只允许申请该阅片人最后一次完成裁判的任务重阅)申请的时候做了限制
case ReadingCategory.Judge:
- // 1、后续任务如果是访视任务、全局任务,均不处理;
- //2、后续若有肿瘤学阅片,若肿瘤学阅片任务状态为阅片完成,则标记为重阅重置;若为阅片中则标记为失效,如为待阅片,则取消分配
-
//裁判的影响自己 和后续肿瘤学阅片(不是自己做的)
- filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.VisitTaskNum > filterObj.VisitTaskNum && t.ReadingCategory == ReadingCategory.Oncology);
+ filterExpression = filterExpression.And(t => t.Id == origenalTask.Id || t.VisitTaskNum > origenalTask.VisitTaskNum && t.ReadingCategory == ReadingCategory.Oncology);
break;
@@ -2740,373 +1870,1242 @@ namespace IRaCIS.Core.Application.Service.Allocation
default:
//---不支持重阅的任务类型
throw new BusinessValidationFailedException(_localizer["VisitTask_UnsupportedTaskType"]);
+
}
+
+ #endregion
+
+
+
+ var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).OrderBy(t => t.VisitTaskNum).ToListAsync();
+
+ var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
+
+
+
+ foreach (var influenceTask in influenceTaskList)
+ {
+ var beforeTaskState = influenceTask.TaskState;
+
+ //已签名的任务 设置转变后的标志
+ if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ var isConvertedTask = _visitTaskRepository.Where(t => t.Id == influenceTask.Id).Select(t => t.IsConvertedTask).FirstOrDefault();
+
+ if (isConvertedTask)
+ {
+ influenceTask.IsHistoryConvertedTask = true;
+ }
+ }
+
+
+ //处理申请的任务
+ if (influenceTask.Id == origenalTask.Id)
+ {
+ ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
+
+
+ await SetMedicalReviewInvalidAsync(influenceTaskList, false);
+
+ await InfluenceAddtioncalEvaluationCritrionAsync(origenalTask, influenceTaskList.Where(t => t.Id != origenalTask.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => t.SourceSubjectVisitId!.Value).Distinct().ToList(), false);
+
+ }
+
+
+
+ if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ influenceTask.TaskState = TaskState.HaveReturned;
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
+ }
+ else
+ {
+ influenceTask.TaskState = TaskState.Adbandon;
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
+ }
+
+
+ #region 受影响的任务生成
+
+ // 影响的任务 仅仅访视类别的才生成 或者就是IR 申请的任务
+ if (influenceTask.ReadingCategory == ReadingCategory.Visit || influenceTask.Id == origenalTask.Id)
+ {
+
+
+ // 影响的其他标准的附加评估的任务不立即生成 比如1.1基线 重阅 PM 同意仅仅生成1.1任务,不生成BM任务
+ if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment && influenceTask.TrialReadingCriterionId != origenalTask.TrialReadingCriterionId)
+ {
+ //BM标准的不生成任务
+ continue;
+ }
+
+
+ // i1.1标准 当前任务是转变任务,并且影响列表里有转变之前的任务 那么该访视任务就不生成
+ if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1)
+ {
+ //申请的任务是冻结的任务(该任务发生转变) 影响自己 以及转变后的 以及后续任务 但是生成的时候,仅仅生成转变之前的
+ //申请的是转变之后的任务 (转变生成的任务) 影响自己以及后续任务 生成转变后的任务
+ if (influenceTask.BeforeConvertedTaskId != null && influenceTaskList.Any(t => t.Id == influenceTask.BeforeConvertedTaskId))
+ {
+ //有转化的任务 和转化之前的任务时,转化后的任务时不生成的
+ continue;
+
+ }
+
+
+ }
+
+
+ await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
+ {
+ TrialId = trialId,
+
+ ReadingCategory = GenerateTaskCategory.ReReading,
+
+ ReReadingTask = influenceTask,
+
+ //同步才可以
+ Action = (newTask) =>
+ {
+ //申请表 设置新任务Id
+ visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
+
+ //生成的任务分配给原始医生
+ newTask.DoctorUserId = origenalTask.DoctorUserId;
+ newTask.TaskAllocationState = TaskAllocationState.Allocated;
+ newTask.AllocateTime = DateTime.Now;
+ newTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget);
+
+ //拷贝原始表单
+ if (visitTaskReReadingAppply.IsCopyOrigenalForms && influenceTask.Id == origenalTask.Id)
+ {
+ if (origenalTask.ReadingCategory == ReadingCategory.Visit)
+ {
+ CopyForms(newTask, origenalTask);
+
+ }
+
+ }
+
+ //拷贝后续表单
+ if (visitTaskReReadingAppply.IsCopyFollowForms && origenalTask.VisitTaskNum != influenceTask.VisitTaskNum)
+ {
+ if (origenalTask.ReadingCategory == ReadingCategory.Visit)
+ {
+ CopyForms(newTask, origenalTask);
+ }
+
+
+ }
+
+ }
+ });
+
+
+
+ #endregion
+
+
+ }
+
+ }
+
+
+
}
- //无序
+ //无序阅片 IR只会申请访视类型和裁判类型的任务 注意这里有一致性分析的申请同意
else
{
+
+
//1.当前任务及裁判任务
//2.影响当前阅片人的任务
- filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.Id == filterObj.JudgeVisitTaskId);
- }
+ filterExpression = filterExpression.And(t => t.Id == origenalTask.Id || t.Id == origenalTask.JudgeVisitTaskId);
- //throw new BusinessValidationFailedException("仅允许PM 同意 IR 申请的任务");
- }
- //PM 影响所有阅片人 仅仅针对访视 SPM CPM 调用
+ var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
- else if (((IsSpmOrCPM()) && applyId != null &&
- await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && (t.CreateUser.UserTypeEnum == UserTypeEnum.ProjectManager || t.CreateUser.UserTypeEnum == UserTypeEnum.APM)) && filterObj.IsAnalysisCreate == false && filterObj.ReadingCategory == ReadingCategory.Visit)
- || (IsPMOrAPm() && applyId == null))
- {
+ var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault();
-
-
-
- //有序
- if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
- {
- switch (filterObj.ReadingCategory)
+ foreach (var influenceTask in influenceTaskList)
{
- case ReadingCategory.Visit:
+ //申请原任务处理
+ if (influenceTask.Id == origenalTask.Id)
+ {
+ ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand);
- //访视影响当前以及当前之后的 两个阅片人的
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum);
+ await SetMedicalReviewInvalidAsync(influenceTaskList, false);
- break;
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
+ }
+ else
+ {
+ if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ influenceTask.TaskState = TaskState.HaveReturned;
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
+ }
+ else
+ {
+ influenceTask.TaskState = TaskState.Adbandon;
+
+ trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
+ }
+ }
+
+ #region 受影响任务的生成
+
+ if (influenceTask.ReadingCategory == ReadingCategory.Visit || influenceTask.Id == origenalTask.Id)
+ {
+ await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
+ {
+ TrialId = trialId,
+
+ ReadingCategory = GenerateTaskCategory.ReReading,
+
+ ReReadingTask = origenalTask,
+
+ //同步才可以
+ Action = (newTask) =>
+ {
+ //申请表 设置新任务Id
+ visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
+
+ ////生成的任务分配给原始医生
+ newTask.DoctorUserId = origenalTask.DoctorUserId;
+ newTask.TaskAllocationState = TaskAllocationState.Allocated;
+ newTask.AllocateTime = DateTime.Now;
+ newTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget);
+
+
+ //裁判任务 需要进行特殊处理 在重阅逻辑里面处理
+
+
+ if (visitTaskReReadingAppply.IsCopyOrigenalForms && influenceTask.Id == origenalTask.Id)
+ {
+ if (origenalTask.ReadingCategory == ReadingCategory.Visit)
+ {
+ CopyForms(newTask, origenalTask);
+
+ }
+
+ }
+
+ //拷贝后续表单
+ if (visitTaskReReadingAppply.IsCopyFollowForms && origenalTask.VisitTaskNum != influenceTask.VisitTaskNum)
+ {
+ if (origenalTask.ReadingCategory == ReadingCategory.Visit)
+ {
+ CopyForms(newTask, origenalTask);
+
+ }
+ }
+
+
+ }
+ });
+
+ }
+ #endregion
- default:
- //---不支持重阅的任务类型
- throw new BusinessValidationFailedException(_localizer["VisitTask_UnsupportedTaskType"]);
}
- if (await _visitTaskReReadingRepository.AnyAsync(t => t.RequestReReadingType == RequestReReadingType.DocotorApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default &&
- t.OriginalReReadingTask.VisitTaskNum >= filterObj.VisitTaskNum && t.OriginalReReadingTask.SubjectId == filterObj.SubjectId && t.OriginalReReadingTask.TrialReadingCriterionId == filterObj.TrialReadingCriterionId && t.OriginalReReadingTask.IsAnalysisCreate == filterObj.IsAnalysisCreate))
- {
- isIRAppyTaskInfluenced = true;
- }
- }
- //无序
- else
- {
- // 1.当前任务及裁判任务
- // 2.影响所有阅片人的任务
-
- var judegTaskNum = filterObj.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge];
-
- filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum || t.VisitTaskNum == judegTaskNum);
}
- //throw new BusinessValidationFailedException("仅允许SPM CPM 同意 PM 申请的非 一致性分析的访视任务");
}
else
{
- //---当前用户查看列表未定义
- throw new BusinessValidationFailedException(_localizer["VisitTask_UndefinedList"]);
+ //---不符合 PM申请 SPM / CPM审批 | IR申请 PM 审批
+ throw new BusinessValidationFailedException(_localizer["VisitTask_ReReadTaskAlreadyAffected"]);
}
-
-
}
-
-
- //退回影响 仅仅针对是访视类型的 影响多个标准的任务
- else
+ else if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Reject)
{
- if (filterObj.IsAnalysisCreate)
+ if (origenalTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || origenalTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
{
- //---不允许退回一致性分析任务
- throw new BusinessValidationFailedException(_localizer["VisitTask_NoConsistencyReturn"]);
- }
-
- if (filterObj.ReadingCategory == ReadingCategory.Visit && IsPMOrAPm())
- {
- //有序
- if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == origenalTask.Id, u => new VisitTask()
{
- // 当前任务及其之后的所有访视任务 两个阅片人的
-
- //2.当前任务未完成,不会产生全局任务。后续任务均为访视任务,且均为待阅片,取消分配;
- filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum);
-
-
- if (await _visitTaskReReadingRepository.AnyAsync(t => t.RequestReReadingType == RequestReReadingType.DocotorApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default &&
- t.OriginalReReadingTask.VisitTaskNum >= filterObj.VisitTaskNum && t.OriginalReReadingTask.SubjectId == filterObj.SubjectId && t.OriginalReReadingTask.TrialReadingCriterionId == filterObj.TrialReadingCriterionId && t.OriginalReReadingTask.IsAnalysisCreate == filterObj.IsAnalysisCreate))
- {
- isIRAppyTaskInfluenced = true;
- }
- }
- //无序
- else
- {
- //自己和另一个人的当前任务 退回针对的是未完成的肯定不会有裁判
- filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum);
- }
+ ReReadingApplyState = ReReadingApplyState.Reject
+ });
}
else
{
- //---仅仅访视类型的任务支持PM退回
- throw new BusinessValidationFailedException(_localizer["VisitTask_VisitTypeTaskAllowedForPMOnly"]);
+ //---当前重阅任务状态不为已申请状态,不允许进行处理,请刷新页面
+ throw new BusinessValidationFailedException(_localizer["VisitTask_InvalidReapplyStatus"]);
}
}
- var list = await _visitTaskRepository.Where(filterExpression)
- //IR 申请的时候,仅仅看到影响自己的
- .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer, t => t.DoctorUserId == _userInfo.Id)
- .OrderBy(t => t.VisitTaskNum).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
- #region 影响后的操作
- foreach (var influenceTask in list)
+
+ }
+
+
+
+
+
+ await _visitTaskRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok();
+ }
+
+ private void CopyForms(VisitTask newTask, VisitTask origenalTask)
+ {
+
+ //自定义
+ var readingCustomTagList = _readingCustomTagRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
+
+ foreach (var item in readingCustomTagList)
+ {
+ item.Id = Guid.Empty;
+ item.VisitTaskId = newTask.Id;
+ }
+
+ _ = _readingCustomTagRepository.AddRangeAsync(readingCustomTagList).Result;
+
+
+ var readingTaskQuestionMarkList = _readingTaskQuestionMarkRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
+
+ foreach (var item in readingTaskQuestionMarkList)
+ {
+ item.Id = Guid.Empty;
+ item.VisitTaskId = newTask.Id;
+ }
+
+ _ = _readingTaskQuestionMarkRepository.AddRangeAsync(readingTaskQuestionMarkList).Result;
+
+ var readingTaskQuestionAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
+
+ foreach (var item in readingTaskQuestionAnswerList)
+ {
+ item.Id = Guid.Empty;
+ item.VisitTaskId = newTask.Id;
+ }
+ _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(readingTaskQuestionAnswerList).Result;
+
+
+
+ //ReadingTableAnswerRowInfo ReadingTableQuestionAnswer 一起加
+ var readingTableAnswerRowInfoList = _readingTableAnswerRowInfoRepository.Where(t => t.VisitTaskId == origenalTask.Id).Include(t => t.LesionAnswerList).ToList();
+
+ foreach (var item in readingTableAnswerRowInfoList)
+ {
+
+ var originalVisitTaskId = item.VisitTaskId;
+ var originalFristAddTaskId = item.FristAddTaskId;
+
+ item.Id = NewId.NextSequentialGuid();
+ item.VisitTaskId = newTask.Id;
+
+ //默认值是当前任务添加的
+ item.FristAddTaskId = originalVisitTaskId == originalFristAddTaskId ? newTask.Id : item.FristAddTaskId;
+
+
+ foreach (var item2 in item.LesionAnswerList)
{
- influenceTask.OptType = influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned ? ReReadingOrBackOptType.Return : ReReadingOrBackOptType.Abandon;
+ item2.Id = Guid.Empty;
+ item2.RowId = item.Id;
+ item2.VisitTaskId = newTask.Id;
}
+ }
+
+ _ = _readingTableAnswerRowInfoRepository.AddRangeAsync(readingTableAnswerRowInfoList).Result;
+
+
+
+
+
+ }
+
+
+ ///
+ /// PM 设置任务 退回
+ ///
+ ///
+ [HttpPut("{trialId:guid}/{taskId:guid}")]
+ [UnitOfWork]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+
+ public async Task PMSetTaskBack(Guid trialId, Guid taskId)
+ {
+
+ //var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.IsReadingTaskViewInOrder, t.ReadingType }).FirstOrDefaultAsync()).IfNullThrowException();
+
+
+ var task = (await _visitTaskRepository.Where(t => t.Id == taskId).FirstOrDefaultAsync()).IfNullThrowException();
+
+ var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == task.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.CriterionType, x.IsAutoCreate, x.IsAdditionalAssessment, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
+
+ if (criterionConfig.IsAutoCreate == false)
+ {
+ //---手动生成任务的不允许在此入口影像退回
+ return ResponseOutput.NotOk(_localizer["VisitTask_NoImageReturn"]);
+ }
+
+ if (task.TaskState != TaskState.Effect || task.ReadingCategory != ReadingCategory.Visit || task.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ //---仅仅允许针对生效、未完成的访视任务进行退回操作,请刷新页面数据
+ return ResponseOutput.NotOk(_localizer["VisitTask_NonEffectiveTaskCannotBeReturned"]);
+ }
+
+
+ if (await _subjectVisitRepository.AnyAsync(t => t.Id == task.SourceSubjectVisitId && t.CheckState != CheckStateEnum.CVPassed))
+ {
+ //---当前访视已回退到影像上传,不允许继续回退!
+ return ResponseOutput.NotOk(_localizer["VisitTask_NoFurtherReturn"]);
+ }
+
+
+ if (task.IsAnalysisCreate)
+ {
+ //---一致性分析的任务,不允许设置退回
+ return ResponseOutput.NotOk(_localizer["VisitTask_ConsistencyTaskCannotBeReturned"]);
+ }
+
+ Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == task.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.TaskAllocationState == TaskAllocationState.Allocated;
+
+
+ #region 退回到访视 不区分标准
+ //if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment)
+ //{
+ // //影像退回,必定影响两个标准的任务
+ // filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == task.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
+
+
+ //}
+ //else
+ //{
+ // //默认影响的都是该标准的任务
+ // filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == task.TrialReadingCriterionId);
+ //}
+ #endregion
+
+
+ //PM 才允许操作
+ if (IsPMOrAPm())
+ {
+
+ #region 有序 无序公用流程
+
+
+ //执行类似一致性核查回退流程 回退访视到影像上传流程
+ await VisitBackAsync(task.SourceSubjectVisitId);
+
#endregion
- return (list, new { IsIRAppyTaskInfluenced = isIRAppyTaskInfluenced });
+
+ //有序
+ if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ {
+
+ //Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && t.TaskAllocationState == TaskAllocationState.Allocated;
+
+ filterExpression = filterExpression.And(t => t.IsAnalysisCreate == false);
+
+
+
+ //另一个阅片人的任务根据任务进度自动进入PM退回或PM申请重阅
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= task.VisitTaskNum);
+
+
+ var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
+
+
+
+ #region 方式二
+
+
+ //pm退回的时候,影响的任务里不一定有该任务id 双重 分配了一个人,退回的时候,选择的是未分配的
+
+ //var origenalTask = influenceTaskList.Where(t => t.Id == task.Id).FirstOrDefault();
+
+ var origenalTask = await _visitTaskRepository.FindAsync(task.Id);
+
+
+ foreach (var influenceTask in influenceTaskList)
+ {
+
+ //已签名的任务 设置转变后的标志
+ if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ var isConvertedTask = _visitTaskRepository.Where(t => t.Id == influenceTask.Id).Select(t => t.IsConvertedTask).FirstOrDefault();
+
+ if (isConvertedTask)
+ {
+ influenceTask.IsHistoryConvertedTask = true;
+ }
+ }
+
+ //同意的访视 因为要记录具体的操作,所以废弃
+ if (influenceTask.Id == task.Id)
+ {
+
+ await InfluenceAddtioncalEvaluationCritrionAsync(task, influenceTaskList.Where(t => t.Id != task.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => t.SourceSubjectVisitId!.Value).Distinct().ToList());
+
+ await PMReReadingConfirmOrBackInfluenceAnalysisAsync(influenceTask.SubjectId);
+
+ await SetMedicalReviewInvalidAsync(influenceTaskList);
+
+
+ influenceTask.IsPMSetBack = true;
+ }
+
+ if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ influenceTask.TaskState = TaskState.HaveReturned;
+ origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
+ }
+ else
+ {
+ influenceTask.TaskState = TaskState.Adbandon;
+ origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
+ }
+
+ }
+
+ #endregion
+
+
+
+ }
+
+ else
+ {
+ //无序 无序阅片没有 全局 肿瘤学
+
+ // 申请该访视的任务 申请人失效 另外一个人重阅重置或者失效
+
+ var currentVisitList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.ReadingCategory == ReadingCategory.Visit && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.VisitTaskNum == task.VisitTaskNum, true).ToListAsync();
+
+ await SetMedicalReviewInvalidAsync(currentVisitList);
+
+ //var origenalTask = currentVisitList.Where(t => t.Id == task.Id).First();
+
+ var origenalTask = await _visitTaskRepository.FindAsync(task.Id);
+
+ foreach (var influenceTask in currentVisitList)
+ {
+ if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
+ {
+ //另外阅片人完成阅片了 就设置为重阅重置
+ influenceTask.TaskState = TaskState.HaveReturned;
+
+ origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return });
+ }
+ else
+ {
+ influenceTask.TaskState = TaskState.Adbandon;
+
+ origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon });
+ }
+
+ }
+
+ }
}
-
-
-
-
- ///
- /// 获取已影响的列表
- ///
- ///
- public async Task> GetInfluencedTaskList(Guid taskId)
+ else
{
- var list = await _taskInfluenceRepository.Where(t => t.OriginalTaskId == taskId)/*.Select(t => t.InfluenceTask)*/.ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
-
- return list;
+ //---仅PM 可以进行回退操作
+ return ResponseOutput.NotOk(_localizer["VisitTask_PMOnlyAllowedForReturn"]);
}
- #region 暂时废弃
-
-
- /////
- ///// 自动一次性分配所有未分配的 Subject 给医生 暂时废弃
- /////
- /////
- /////
- //[HttpPost]
- //[UnitOfWork]
- //[Obsolete]
- //public async Task AutoSubjectAssignDoctor(AutoSubjectAssignCommand autoSubjectAssignCommand)
- //{
- // //自动分配的话,需要把手动分配的给删掉
-
-
- // var trialId = autoSubjectAssignCommand.TrialId;
- // var isJudge = autoSubjectAssignCommand.IsJudgeDoctor;
-
-
- // //获取项目配置 判断应该分配几个医生
- // var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id/*, t.ReadingType*/, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign, t.FollowGlobalVisitAutoAssignDefaultState, t.TaskAllocateObjEnum }).FirstOrDefaultAsync()).IfNullThrowException();
-
-
- // //获取 已产生任务的Subject 目前分配情况
- // var subjectList = _subjectRepository.Where(t => t.TrialId == trialId)
- // .WhereIf(isJudge == false, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
- // .WhereIf(isJudge, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
- // ////过滤掉 那些回退的subject
- // //.Where(t => !t.SubjectVisitList.Any(t => t.IsPMBackOrReReading))
- // .Select(t => new
- // {
- // SubjectId = t.Id,
-
- // //给Subject分配医生的时候, 未确认绑定关系的
- // DoctorUserList = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).Select(t => new { t.DoctorUserId, t.ArmEnum }),
- // //IsApplyed = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).SelectMany(t => t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null)
- // IsApplyed = false
- // }).ToList();
-
- // //已产生任务的Subject数量(裁判情况下,就是产生裁判任务Subject 的数量)
- // var subjectCount = subjectList.Count;
-
- // //获取医生列表(裁判是裁判的医生列表)
- // var waitAllocationDoctorList = _taskAllocationRuleRepository.Where(t => t.TrialId == trialId && t.IsEnable)
- // .Where(t => t.IsJudgeDoctor == isJudge)
- // .Select(t => new AutoAssignResultDTO() { DoctorUserId = t.DoctorUserId, PlanReadingRatio = t.PlanReadingRatio, SubjectCount = subjectCount })
- // .ToList();
-
- // if (waitAllocationDoctorList.Count == 0)
- // {
- // throw new BusinessValidationFailedException("启用的医生数量为0");
- // }
-
-
- // //已分配的 医生的情况
- // var haveAssignedSubjectDoctorList = subjectList.Clone().SelectMany(t => t.DoctorUserList.Select(c => new { t.SubjectId, c.DoctorUserId, c.ArmEnum })).ToList();
-
- // //将目前已分配的情况 换到医生的维度
- // foreach (var waitAllocationDoctor in waitAllocationDoctorList)
- // {
- // waitAllocationDoctor.SubjectArmList = haveAssignedSubjectDoctorList.Where(t => t.DoctorUserId == waitAllocationDoctor.DoctorUserId)
- // .Select(g => new SubjectArm()
- // {
- // SubjectId = g.SubjectId,
- // ArmEnum = g.ArmEnum
- // }).ToList();
- // }
-
-
- // #region 完全按照Subject 遍历去分
-
-
- // //仅仅分配未应用的 而且 没有分配医生的
- // foreach (var subject in subjectList.Where(t => t.IsApplyed == false && !t.DoctorUserList.Any()))
- // {
- // //该Subject 已经分配的医生数量
- // var hasAssignDoctorCount = subject.DoctorUserList.Count();
-
- // if (isJudge)
- // {
- // if (hasAssignDoctorCount > 1)
- // {
- // throw new BusinessValidationFailedException("当前有Subject裁判绑定医生数量大于1");
-
- // }
-
- // var allocateDoctor = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault();
-
- // //将分配结果记录
- // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctor.DoctorUserId).SubjectArmList.Add(new SubjectArm()
- // {
- // SubjectId = subject.SubjectId,
- // ArmEnum = Arm.JudgeArm
- // });
-
- // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = Arm.JudgeArm, AssignTime = DateTime.Now });
-
- // }
- // else
- // {
-
- // //分配两个医生
- // if (trialConfig.ReadingType == ReadingMethod.Double)
- // {
-
-
- // if (hasAssignDoctorCount > 2)
- // {
- // throw new BusinessValidationFailedException("双重阅片当前有Subject绑定医生数量大于2");
-
- // }
-
- // var allocateDoctorList = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).Take(2).ToList();
-
-
- // #region 看阅片人之前在Subject哪个组做的多
-
- // var preferredDoctor1Arm = waitAllocationDoctorList.Where(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId)
- // .SelectMany(t => t.SubjectArmList).GroupBy(t => t.ArmEnum)
- // .Select(g => new { ArmEnum = g.Key, SubjectCount = g.Count() })
- // .OrderByDescending(t => t.SubjectCount).FirstOrDefault()?.ArmEnum;
-
- // var preferredDoctor2Arm = waitAllocationDoctorList.Where(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId)
- // .SelectMany(t => t.SubjectArmList).GroupBy(t => t.ArmEnum)
- // .Select(g => new { ArmEnum = g.Key, SubjectCount = g.Count() })
- // .OrderByDescending(t => t.SubjectCount).FirstOrDefault()?.ArmEnum;
-
- // //存放医生分配的Arm
- // var doctor1Arm = Arm.DoubleReadingArm1;
- // var doctor2Arm = Arm.DoubleReadingArm2;
-
- // if (preferredDoctor1Arm == null && preferredDoctor2Arm == null ||
- // preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm2 ||
- // preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == null ||
- // preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm2
- // )
- // {
- // doctor1Arm = Arm.DoubleReadingArm1;
- // doctor2Arm = Arm.DoubleReadingArm2;
- // }
- // else if (preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm1 ||
- // preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm1 ||
- // preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == null)
- // {
- // doctor1Arm = Arm.DoubleReadingArm2;
- // doctor2Arm = Arm.DoubleReadingArm1;
- // }
-
- // else if (preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm1)
- // {
- // doctor1Arm = Arm.DoubleReadingArm1;
- // doctor2Arm = Arm.DoubleReadingArm2;
- // }
- // else if (preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm2)
- // {
- // doctor1Arm = Arm.DoubleReadingArm2;
- // doctor2Arm = Arm.DoubleReadingArm1;
- // }
-
- // #endregion
-
-
- // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[0].DoctorUserId, ArmEnum = doctor1Arm, AssignTime = DateTime.Now });
-
-
- // //将分配结果记录
- // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId).SubjectArmList.Add(new SubjectArm()
- // {
- // SubjectId = subject.SubjectId,
- // ArmEnum = doctor1Arm
- // });
-
-
- // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[1].DoctorUserId, ArmEnum = doctor2Arm, AssignTime = DateTime.Now });
-
- // //将分配结果记录
- // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId).SubjectArmList.Add(new SubjectArm()
- // {
- // SubjectId = subject.SubjectId,
- // ArmEnum = doctor2Arm
- // });
- // }
- // else if (trialConfig.ReadingType == ReadingMethod.Single)
- // {
- // if (hasAssignDoctorCount > 1)
- // {
- // throw new BusinessValidationFailedException("单重阅片当前有Subject绑定医生数量大于1");
- // }
-
- // var allocateDoctor = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault();
-
- // //将分配结果记录
- // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctor.DoctorUserId).SubjectArmList.Add(new SubjectArm()
- // {
- // SubjectId = subject.SubjectId,
- // ArmEnum = Arm.SingleReadingArm
- // });
-
- // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = Arm.SingleReadingArm, AssignTime = DateTime.Now });
-
- // }
-
- // }
-
- // }
-
-
- // #endregion
+ await _visitTaskRepository.SaveChangesAsync();
-
-
- // await _subjectUserRepository.SaveChangesAsync();
- // return ResponseOutput.Ok();
-
- //}
-
-
- #endregion
+ return ResponseOutput.Ok();
}
+
+
+ ///
+ /// 基线退回 影响附加评估标准 是否参与评估
+ ///
+ ///
+ private async Task InfluenceAddtioncalEvaluationCritrionAsync(VisitTask task, List otherVisitIdList, bool isImageBack = true)
+ {
+
+ var criterion = await _trialReadingCriterionRepository.FindAsync(task.TrialReadingCriterionId);
+
+ if (criterion.CriterionType == CriterionType.RECIST1Point1)
+ {
+ //影像回退了|| IR 申请及基线重阅
+ if (_subjectVisitRepository.Any(t => t.Id == task.SourceSubjectVisitId && t.IsBaseLine))
+ {
+ await _subjectCriteriaEvaluationRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.IsAutoCreate == false && t.SubjectId == task.SubjectId, u => new SubjectCriteriaEvaluation()
+ {
+ IsJoinEvaluation = false
+ });
+
+ //删除筛选的访视数据
+ await _subjectCriteriaEvaluationVisitFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectId == task.SubjectId);
+
+ //删除筛选的序列数据
+ await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId);
+ }
+ else if (isImageBack)
+ {
+ //当前访视筛选状态重置,任务生成状态重置
+ if (task.SourceSubjectVisitId != null)
+ {
+ await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && t.SubjectVisitId == task.SourceSubjectVisitId,
+ t => new SubjectCriteriaEvaluationVisitFilter()
+ {
+ ImageFilterState = ImageFilterState.None,
+ ImageDeterminationResultState = ImageDeterminationResultState.None,
+ IsGeneratedTask = false
+ });
+
+ //删除序列数据
+ await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && t.SubjectVisitId == task.SourceSubjectVisitId);
+ }
+
+
+ //BM后续访视 ,筛选状态不变,任务生成状态重置(实际该访视任务状态 可能是重阅重置了或者失效了,需要后续生成,或者取消分配了,需要后续重新分配)
+ await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && otherVisitIdList.Contains(t.SubjectVisitId),
+ t => new SubjectCriteriaEvaluationVisitFilter()
+ {
+ IsGeneratedTask = false
+ });
+ }
+ else
+ {
+ //IR 端 非基线申请重阅 不影响
+ }
+ }
+
+
+
+ }
+
+ //包括临床数据签名状态
+ private async Task VisitBackAsync(Guid? subjectVisitId)
+ {
+ var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException();
+
+
+ //需要重新产生任务
+ sv.IsVisitTaskGenerated = false;
+ sv.IsPMBackOrReReading = true;
+
+ sv.AuditState = AuditStateEnum.None;
+ sv.SubmitState = SubmitStateEnum.ToSubmit;
+ sv.ReadingStatus = ReadingStatusEnum.ImageNotSubmit;
+
+ //回退后,回退状态恢复
+ sv.RequestBackState = RequestBackStateEnum.NotRequest;
+ sv.IsCheckBack = false;
+ sv.CheckBackTime = null;
+ sv.CheckState = CheckStateEnum.None;
+ sv.CheckChallengeState = CheckChanllengeTypeEnum.None;
+
+ sv.SVENDTC = null;
+ sv.SVSTDTC = null;
+
+ sv.PreliminaryAuditTime = null;
+ sv.SubmitTime = null;
+ sv.ReviewAuditTime = null;
+ sv.CurrentActionUserExpireTime = null;
+
+
+ sv.IsTake = false;
+ sv.CurrentActionUserId = null;
+ sv.PreliminaryAuditUserId = null;
+ sv.ReviewAuditUserId = null;
+
+
+ if (sv.IsBaseLine)
+ {
+ await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && (t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.Subject || t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit), c => new ReadingClinicalData() { IsSign = false, ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded });
+
+ }
+ else
+ {
+ await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit, c => new ReadingClinicalData()
+ {
+ IsSign = false,
+ ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded,
+ IsBlind = null,
+ IsComplete = null
+ });
+ }
+
+
+
+ //await _repository.AddAsync(new CheckChallengeDialog() { SubjectVisitId = subjectVisitId, TalkContent = "PM/APM同意一致性核查回退。", UserTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt });
+
+ await _trialQCQuestionAnswerRepository.BatchDeleteNoTrackingAsync(t => t.SubjectVisitId == subjectVisitId);
+ await _dicomInstanceRepository.BatchDeleteNoTrackingAsync(t => t.DicomSerie.IsDeleted);
+ await _dicomSeriesRepository.BatchDeleteNoTrackingAsync(t => t.IsDeleted);
+
+ var success = await _subjectVisitRepository.SaveChangesAsync();
+
+ }
+
+
+ private bool IsPMOrAPm()
+ {
+ return _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM;
+ }
+
+ private bool IsSpmOrCPM()
+ {
+ return _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM;
+ }
+
+ ///
+ /// 影响提示列表 重阅仅仅针对已完成的任务申请 退回针对的是未完成的(退回仅仅针对是访视类型的)
+ ///
+ ///
+ /// 重阅还是直接回退
+ /// 申请记录的Id
+ ///
+ [HttpGet("{taskId:guid}/{isReReading:bool}")]
+ public async Task<(List, object)> GetReReadingOrBackInfluenceTaskList(Guid taskId, bool isReReading, Guid? applyId)
+ {
+ var isIRAppyTaskInfluenced = false;
+
+ var filterObj = (await _visitTaskRepository.FirstOrDefaultNoTrackingAsync(t => t.Id == taskId)).IfNullThrowException();
+ var trialId = filterObj.TrialId;
+
+ var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == filterObj.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.CriterionType, x.IsAdditionalAssessment, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
+
+ Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.TaskAllocationState == TaskAllocationState.Allocated;
+
+ //是否是一致性分析任务 (一致性分析的任务 不会产生裁判 肿瘤学 仅仅有生成的访视和全局)
+
+ filterExpression = filterExpression.And(t => t.IsAnalysisCreate == filterObj.IsAnalysisCreate);
+
+ //IR 申请1.1 基线重阅,影响附加评估所有的任务
+ var isIR1Point1AdditionalAssessmentBaseline = false;
+
+ //附加评估 IR 和PM 看到的影响列表不一样
+ if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment)
+ {
+
+ // IR 申请 PM 同意
+ if (((IsPMOrAPm() && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer))
+ || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null)))
+ {
+
+ // 1.1 基线任务影响BM任务
+ if (IsPMOrAPm() && _subjectVisitRepository.Any(t => t.Id == filterObj.SourceSubjectVisitId && t.IsBaseLine == true))
+ {
+
+ isIR1Point1AdditionalAssessmentBaseline = true;
+ //filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
+
+
+ }
+ // 1.1 非基线任务不影响BM任务
+ else
+ {
+ filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId);
+ }
+
+ }
+ //(1、PM回退,PM申请重阅,SPM同意回退)
+ else
+ {
+ filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
+
+ }
+ }
+ else
+ {
+ //默认影响的都是该标准的任务
+ filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId);
+ }
+
+
+
+ //重阅影响
+ if (isReReading)
+ {
+
+
+
+ //IR 申请 PM 同意 仅仅影响自己
+
+ if ((IsPMOrAPm() && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer))
+ || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null))
+ {
+
+ //当前任务及其之后的所有访视任务、全局任务、裁判任务、肿瘤学阅片任务
+
+ //有序
+ if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ {
+
+ switch (filterObj.ReadingCategory)
+ {
+ case ReadingCategory.Visit:
+ //影响当前医生 以及当前医生之后的 1、访视任务 已经读完的
+ //2、后续任务如果是全局、肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效;
+ //3、当前任务、后续访视任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效
+
+ //申请的是转化的,那么影响列表要排除转化之前的
+ if (criterionConfig.CriterionType == CriterionType.IRECIST1Point1 && filterObj.BeforeConvertedTaskId != null)
+ {
+
+
+ filterExpression = filterExpression.And(t => (t.VisitTaskNum > filterObj.VisitTaskNum &&
+ (
+ ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == filterObj.DoctorUserId)
+ // 裁判 肿瘤学是另外的医生做
+ || t.ReadingCategory == ReadingCategory.Judge
+ || t.ReadingCategory == ReadingCategory.Oncology
+ )) || t.Id == filterObj.Id)
+ ;
+ }
+ // IR 申请1.1 基线重阅,影响附加评估所有的任务
+ else if (isIR1Point1AdditionalAssessmentBaseline)
+ {
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum &&
+ (((
+ ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == filterObj.DoctorUserId)
+ // 裁判 肿瘤学是另外的医生做
+ || t.ReadingCategory == ReadingCategory.Judge
+ || t.ReadingCategory == ReadingCategory.Oncology
+ ) && t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId) || (t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB))
+ );
+ }
+ else
+ {
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum &&
+ (
+ ((t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == filterObj.DoctorUserId)
+ // 裁判 肿瘤学是另外的医生做
+ || t.ReadingCategory == ReadingCategory.Judge
+ || t.ReadingCategory == ReadingCategory.Oncology
+ )
+ );
+ }
+
+
+
+
+
+ break;
+
+ case ReadingCategory.Global:
+
+ // 1、后续任务如果是访视任务,均不处理;
+ //2、后续任务如果是全局、状态为阅片完成则标记为重阅重置,若阅片中或待阅片则不处理;
+ //3、当前任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效
+ //4、后续任务为肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效;
+
+ //filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum &&
+ //((t.DoctorUserId == filterObj.DoctorUserId && ((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned) || t.ReadingCategory == ReadingCategory.Global)) || (t.ReadingCategory == ReadingCategory.Oncology) || (t.ReadingCategory == ReadingCategory.Judge)));
+
+
+ filterExpression = filterExpression.And(t => t.VisitTaskNum > filterObj.VisitTaskNum &&
+ (
+ (t.DoctorUserId == filterObj.DoctorUserId && t.ReadingCategory == ReadingCategory.Global)
+ || (t.ReadingCategory == ReadingCategory.Oncology)
+ || (t.ReadingCategory == ReadingCategory.Judge)
+ ) || t.Id == filterObj.Id);
+
+ break;
+
+ //1、后续任务如果是访视任务、全局任务或裁判任务,均不处理;
+ case ReadingCategory.Oncology:
+
+ //仅仅影响自己
+ filterExpression = filterExpression.And(t => t.Id == filterObj.Id);
+ break;
+
+ //(只允许申请该阅片人最后一次完成裁判的任务重阅)申请的时候做了限制
+ case ReadingCategory.Judge:
+
+ // 1、后续任务如果是访视任务、全局任务,均不处理;
+ //2、后续若有肿瘤学阅片,若肿瘤学阅片任务状态为阅片完成,则标记为重阅重置;若为阅片中则标记为失效,如为待阅片,则取消分配
+
+ //裁判的影响自己 和后续肿瘤学阅片(不是自己做的)
+ filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.VisitTaskNum > filterObj.VisitTaskNum && t.ReadingCategory == ReadingCategory.Oncology);
+
+ break;
+
+
+ default:
+ //---不支持重阅的任务类型
+ throw new BusinessValidationFailedException(_localizer["VisitTask_UnsupportedTaskType"]);
+ }
+ }
+ //无序
+ else
+ {
+ //1.当前任务及裁判任务
+ //2.影响当前阅片人的任务
+ filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.Id == filterObj.JudgeVisitTaskId);
+ }
+
+
+ //throw new BusinessValidationFailedException("仅允许PM 同意 IR 申请的任务");
+ }
+ //PM 影响所有阅片人 仅仅针对访视 SPM CPM 调用
+
+ else if (((IsSpmOrCPM()) && applyId != null &&
+ await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && (t.CreateUser.UserTypeEnum == UserTypeEnum.ProjectManager || t.CreateUser.UserTypeEnum == UserTypeEnum.APM)) && filterObj.IsAnalysisCreate == false && filterObj.ReadingCategory == ReadingCategory.Visit)
+ || (IsPMOrAPm() && applyId == null))
+ {
+
+
+
+
+ //有序
+ if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ {
+ switch (filterObj.ReadingCategory)
+ {
+ case ReadingCategory.Visit:
+
+ //访视影响当前以及当前之后的 两个阅片人的
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum);
+
+ break;
+
+ default:
+ //---不支持重阅的任务类型
+ throw new BusinessValidationFailedException(_localizer["VisitTask_UnsupportedTaskType"]);
+ }
+
+ if (await _visitTaskReReadingRepository.AnyAsync(t => t.RequestReReadingType == RequestReReadingType.DocotorApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default &&
+ t.OriginalReReadingTask.VisitTaskNum >= filterObj.VisitTaskNum && t.OriginalReReadingTask.SubjectId == filterObj.SubjectId && t.OriginalReReadingTask.TrialReadingCriterionId == filterObj.TrialReadingCriterionId && t.OriginalReReadingTask.IsAnalysisCreate == filterObj.IsAnalysisCreate))
+ {
+ isIRAppyTaskInfluenced = true;
+ }
+ }
+ //无序
+ else
+ {
+ // 1.当前任务及裁判任务
+ // 2.影响所有阅片人的任务
+
+ var judegTaskNum = filterObj.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge];
+
+ filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum || t.VisitTaskNum == judegTaskNum);
+ }
+
+ //throw new BusinessValidationFailedException("仅允许SPM CPM 同意 PM 申请的非 一致性分析的访视任务");
+ }
+ else
+ {
+ //---当前用户查看列表未定义
+ throw new BusinessValidationFailedException(_localizer["VisitTask_UndefinedList"]);
+ }
+
+
+
+ }
+
+
+ //退回影响 仅仅针对是访视类型的 影响多个标准的任务
+ else
+ {
+
+ if (filterObj.IsAnalysisCreate)
+ {
+ //---不允许退回一致性分析任务
+ throw new BusinessValidationFailedException(_localizer["VisitTask_NoConsistencyReturn"]);
+ }
+
+ if (filterObj.ReadingCategory == ReadingCategory.Visit && IsPMOrAPm())
+ {
+ //有序
+ if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
+ {
+ // 当前任务及其之后的所有访视任务 两个阅片人的
+
+ //2.当前任务未完成,不会产生全局任务。后续任务均为访视任务,且均为待阅片,取消分配;
+ filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum);
+
+
+ if (await _visitTaskReReadingRepository.AnyAsync(t => t.RequestReReadingType == RequestReReadingType.DocotorApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default &&
+ t.OriginalReReadingTask.VisitTaskNum >= filterObj.VisitTaskNum && t.OriginalReReadingTask.SubjectId == filterObj.SubjectId && t.OriginalReReadingTask.TrialReadingCriterionId == filterObj.TrialReadingCriterionId && t.OriginalReReadingTask.IsAnalysisCreate == filterObj.IsAnalysisCreate))
+ {
+ isIRAppyTaskInfluenced = true;
+ }
+ }
+ //无序
+ else
+ {
+ //自己和另一个人的当前任务 退回针对的是未完成的肯定不会有裁判
+ filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum);
+ }
+ }
+ else
+ {
+ //---仅仅访视类型的任务支持PM退回
+ throw new BusinessValidationFailedException(_localizer["VisitTask_VisitTypeTaskAllowedForPMOnly"]);
+ }
+
+ }
+
+ var list = await _visitTaskRepository.Where(filterExpression)
+ //IR 申请的时候,仅仅看到影响自己的
+ .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer, t => t.DoctorUserId == _userInfo.Id)
+ .OrderBy(t => t.VisitTaskNum).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
+
+ #region 影响后的操作
+
+ foreach (var influenceTask in list)
+ {
+ influenceTask.OptType = influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned ? ReReadingOrBackOptType.Return : ReReadingOrBackOptType.Abandon;
+ }
+ #endregion
+
+
+ return (list, new { IsIRAppyTaskInfluenced = isIRAppyTaskInfluenced });
+
+ }
+
+
+
+
+ ///
+ /// 获取已影响的列表
+ ///
+ ///
+ public async Task> GetInfluencedTaskList(Guid taskId)
+ {
+ var list = await _taskInfluenceRepository.Where(t => t.OriginalTaskId == taskId)/*.Select(t => t.InfluenceTask)*/.ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
+
+ return list;
+ }
+
+
+ #region 暂时废弃
+
+
+ /////
+ ///// 自动一次性分配所有未分配的 Subject 给医生 暂时废弃
+ /////
+ /////
+ /////
+ //[HttpPost]
+ //[UnitOfWork]
+ //[Obsolete]
+ //public async Task AutoSubjectAssignDoctor(AutoSubjectAssignCommand autoSubjectAssignCommand)
+ //{
+ // //自动分配的话,需要把手动分配的给删掉
+
+
+ // var trialId = autoSubjectAssignCommand.TrialId;
+ // var isJudge = autoSubjectAssignCommand.IsJudgeDoctor;
+
+
+ // //获取项目配置 判断应该分配几个医生
+ // var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id/*, t.ReadingType*/, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign, t.FollowGlobalVisitAutoAssignDefaultState, t.TaskAllocateObjEnum }).FirstOrDefaultAsync()).IfNullThrowException();
+
+
+ // //获取 已产生任务的Subject 目前分配情况
+ // var subjectList = _subjectRepository.Where(t => t.TrialId == trialId)
+ // .WhereIf(isJudge == false, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
+ // .WhereIf(isJudge, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
+ // ////过滤掉 那些回退的subject
+ // //.Where(t => !t.SubjectVisitList.Any(t => t.IsPMBackOrReReading))
+ // .Select(t => new
+ // {
+ // SubjectId = t.Id,
+
+ // //给Subject分配医生的时候, 未确认绑定关系的
+ // DoctorUserList = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).Select(t => new { t.DoctorUserId, t.ArmEnum }),
+ // //IsApplyed = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).SelectMany(t => t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null)
+ // IsApplyed = false
+ // }).ToList();
+
+ // //已产生任务的Subject数量(裁判情况下,就是产生裁判任务Subject 的数量)
+ // var subjectCount = subjectList.Count;
+
+ // //获取医生列表(裁判是裁判的医生列表)
+ // var waitAllocationDoctorList = _taskAllocationRuleRepository.Where(t => t.TrialId == trialId && t.IsEnable)
+ // .Where(t => t.IsJudgeDoctor == isJudge)
+ // .Select(t => new AutoAssignResultDTO() { DoctorUserId = t.DoctorUserId, PlanReadingRatio = t.PlanReadingRatio, SubjectCount = subjectCount })
+ // .ToList();
+
+ // if (waitAllocationDoctorList.Count == 0)
+ // {
+ // throw new BusinessValidationFailedException("启用的医生数量为0");
+ // }
+
+
+ // //已分配的 医生的情况
+ // var haveAssignedSubjectDoctorList = subjectList.Clone().SelectMany(t => t.DoctorUserList.Select(c => new { t.SubjectId, c.DoctorUserId, c.ArmEnum })).ToList();
+
+ // //将目前已分配的情况 换到医生的维度
+ // foreach (var waitAllocationDoctor in waitAllocationDoctorList)
+ // {
+ // waitAllocationDoctor.SubjectArmList = haveAssignedSubjectDoctorList.Where(t => t.DoctorUserId == waitAllocationDoctor.DoctorUserId)
+ // .Select(g => new SubjectArm()
+ // {
+ // SubjectId = g.SubjectId,
+ // ArmEnum = g.ArmEnum
+ // }).ToList();
+ // }
+
+
+ // #region 完全按照Subject 遍历去分
+
+
+ // //仅仅分配未应用的 而且 没有分配医生的
+ // foreach (var subject in subjectList.Where(t => t.IsApplyed == false && !t.DoctorUserList.Any()))
+ // {
+ // //该Subject 已经分配的医生数量
+ // var hasAssignDoctorCount = subject.DoctorUserList.Count();
+
+ // if (isJudge)
+ // {
+ // if (hasAssignDoctorCount > 1)
+ // {
+ // throw new BusinessValidationFailedException("当前有Subject裁判绑定医生数量大于1");
+
+ // }
+
+ // var allocateDoctor = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault();
+
+ // //将分配结果记录
+ // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctor.DoctorUserId).SubjectArmList.Add(new SubjectArm()
+ // {
+ // SubjectId = subject.SubjectId,
+ // ArmEnum = Arm.JudgeArm
+ // });
+
+ // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = Arm.JudgeArm, AssignTime = DateTime.Now });
+
+ // }
+ // else
+ // {
+
+ // //分配两个医生
+ // if (trialConfig.ReadingType == ReadingMethod.Double)
+ // {
+
+
+ // if (hasAssignDoctorCount > 2)
+ // {
+ // throw new BusinessValidationFailedException("双重阅片当前有Subject绑定医生数量大于2");
+
+ // }
+
+ // var allocateDoctorList = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).Take(2).ToList();
+
+
+ // #region 看阅片人之前在Subject哪个组做的多
+
+ // var preferredDoctor1Arm = waitAllocationDoctorList.Where(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId)
+ // .SelectMany(t => t.SubjectArmList).GroupBy(t => t.ArmEnum)
+ // .Select(g => new { ArmEnum = g.Key, SubjectCount = g.Count() })
+ // .OrderByDescending(t => t.SubjectCount).FirstOrDefault()?.ArmEnum;
+
+ // var preferredDoctor2Arm = waitAllocationDoctorList.Where(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId)
+ // .SelectMany(t => t.SubjectArmList).GroupBy(t => t.ArmEnum)
+ // .Select(g => new { ArmEnum = g.Key, SubjectCount = g.Count() })
+ // .OrderByDescending(t => t.SubjectCount).FirstOrDefault()?.ArmEnum;
+
+ // //存放医生分配的Arm
+ // var doctor1Arm = Arm.DoubleReadingArm1;
+ // var doctor2Arm = Arm.DoubleReadingArm2;
+
+ // if (preferredDoctor1Arm == null && preferredDoctor2Arm == null ||
+ // preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm2 ||
+ // preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == null ||
+ // preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm2
+ // )
+ // {
+ // doctor1Arm = Arm.DoubleReadingArm1;
+ // doctor2Arm = Arm.DoubleReadingArm2;
+ // }
+ // else if (preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm1 ||
+ // preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm1 ||
+ // preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == null)
+ // {
+ // doctor1Arm = Arm.DoubleReadingArm2;
+ // doctor2Arm = Arm.DoubleReadingArm1;
+ // }
+
+ // else if (preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm1)
+ // {
+ // doctor1Arm = Arm.DoubleReadingArm1;
+ // doctor2Arm = Arm.DoubleReadingArm2;
+ // }
+ // else if (preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm2)
+ // {
+ // doctor1Arm = Arm.DoubleReadingArm2;
+ // doctor2Arm = Arm.DoubleReadingArm1;
+ // }
+
+ // #endregion
+
+
+ // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[0].DoctorUserId, ArmEnum = doctor1Arm, AssignTime = DateTime.Now });
+
+
+ // //将分配结果记录
+ // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId).SubjectArmList.Add(new SubjectArm()
+ // {
+ // SubjectId = subject.SubjectId,
+ // ArmEnum = doctor1Arm
+ // });
+
+
+ // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[1].DoctorUserId, ArmEnum = doctor2Arm, AssignTime = DateTime.Now });
+
+ // //将分配结果记录
+ // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId).SubjectArmList.Add(new SubjectArm()
+ // {
+ // SubjectId = subject.SubjectId,
+ // ArmEnum = doctor2Arm
+ // });
+ // }
+ // else if (trialConfig.ReadingType == ReadingMethod.Single)
+ // {
+ // if (hasAssignDoctorCount > 1)
+ // {
+ // throw new BusinessValidationFailedException("单重阅片当前有Subject绑定医生数量大于1");
+ // }
+
+ // var allocateDoctor = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault();
+
+ // //将分配结果记录
+ // waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctor.DoctorUserId).SubjectArmList.Add(new SubjectArm()
+ // {
+ // SubjectId = subject.SubjectId,
+ // ArmEnum = Arm.SingleReadingArm
+ // });
+
+ // await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = Arm.SingleReadingArm, AssignTime = DateTime.Now });
+
+ // }
+
+ // }
+
+ // }
+
+
+ // #endregion
+
+
+
+
+
+
+
+ // await _subjectUserRepository.SaveChangesAsync();
+ // return ResponseOutput.Ok();
+
+ //}
+
+
+ #endregion
}
diff --git a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs
index 8769f96a6..08267c180 100644
--- a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs
+++ b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs
@@ -136,7 +136,6 @@ namespace IRaCIS.Application.Contracts
public Guid? ParentId { get; set; }
public string ParentCode { get; set; } = string.Empty;
- public int? ParentChildCodeEnum { get; set; }
public string ChildGroup { get; set; } = string.Empty;
diff --git a/IRaCIS.Core.Application/Service/Common/DTO/EmailNoticeConfigViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/EmailNoticeConfigViewModel.cs
index c473097a0..52258fa1d 100644
--- a/IRaCIS.Core.Application/Service/Common/DTO/EmailNoticeConfigViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Common/DTO/EmailNoticeConfigViewModel.cs
@@ -96,8 +96,6 @@ namespace IRaCIS.Core.Application.Contracts
/// 业务层级 ///
public int BusinessLevelEnum { get; set; }
- /// 邮件类型 ///
- public int EmailTypeEnum { get; set; }
/// 邮件加急类型 ///
public int EmailUrgentEnum { get; set; }
diff --git a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs
index 13a4d84e2..b2d76c285 100644
--- a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs
@@ -7,7 +7,7 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using IRaCIS.Core.Infra.EFCore.Common.Dto;
+using IRaCIS.Core.Infra.EFCore.Common;
namespace IRaCIS.Core.Application.ViewModel
{
diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs
index 57fe7ac1c..5ad938f17 100644
--- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs
+++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs
@@ -407,7 +407,6 @@ namespace IRaCIS.Application.Services
ChildGroup = x.Dictionary.ChildGroup,
Code = x.Dictionary.Code,
DataTypeEnum = x.Dictionary.DataTypeEnum,
- ParentChildCodeEnum = x.Dictionary.Parent.ChildCodeEnum,
ShowOrder = x.Dictionary.ShowOrder,
ParentCode = x.ParentCode,
CrterionDictionaryGroup = x.CrterionDictionaryGroup,
@@ -427,7 +426,6 @@ namespace IRaCIS.Application.Services
ChildGroup = x.Dictionary.ChildGroup,
Code = x.Dictionary.Code,
DataTypeEnum = x.Dictionary.DataTypeEnum,
- ParentChildCodeEnum = x.Dictionary.Parent.ChildCodeEnum,
ShowOrder = x.Dictionary.ShowOrder,
ParentCode = x.ParentCode,
CrterionDictionaryGroup = x.CrterionDictionaryGroup,
@@ -521,7 +519,6 @@ namespace IRaCIS.Application.Services
Code = x.Dictionary.Code,
Description = x.Dictionary.Description,
DataTypeEnum = x.Dictionary.DataTypeEnum,
- ParentChildCodeEnum = x.Dictionary.Parent.ChildCodeEnum,
ShowOrder = x.Dictionary.ShowOrder,
ParentCode = x.ParentCode,
Id = x.DictionaryId,
@@ -565,7 +562,6 @@ namespace IRaCIS.Application.Services
Code = x.Dictionary.Code,
Description = x.Dictionary.Description,
DataTypeEnum = x.Dictionary.DataTypeEnum,
- ParentChildCodeEnum = x.Dictionary.Parent.ChildCodeEnum,
ShowOrder = x.Dictionary.ShowOrder,
ParentCode = x.ParentCode,
Id = x.DictionaryId,
diff --git a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs
index 916cabf1f..8cd80d6a8 100644
--- a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs
@@ -52,12 +52,12 @@ namespace IRaCIS.Core.Application.Service
CreateMap();
CreateMap()
- .ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum))
+ //.ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum))
.ForMember(o => o.Value, t => t.MapFrom(u => isEn_Us ? u.Value : u.ValueCN))
.ForMember(o => o.ParentCode, t => t.MapFrom(u => u.Parent.Code));
CreateMap()
- .ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum))
+ //.ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum))
.ForMember(o => o.ParentCode, t => t.MapFrom(u => u.Parent.Code));
var token = "";
diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs
index 62e84fc93..c9c49cfde 100644
--- a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs
+++ b/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs
@@ -617,7 +617,6 @@ namespace IRaCIS.Application.Contracts
public List SubspecialityIds { get; set; } = new List();
public Guid Id { get; set; }
- public string OtherSkills { get; set; } = string.Empty;
public string ReadingTypeOther { get; set; } = string.Empty;
public string ReadingTypeOtherCN { get; set; } = string.Empty;
diff --git a/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs b/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs
index 99d2470ad..1082bfa7f 100644
--- a/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs
@@ -105,7 +105,7 @@ namespace IRaCIS.Core.Application.Contracts
public class SystemDocumentQuery : PageInput
{
-
+ public bool? IsDeleted { get; set; }
public Guid? SystemDocumentId { get; set; }
public Guid? FileTypeId { get; set; }
diff --git a/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs b/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs
index 76982a056..432e065bf 100644
--- a/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs
@@ -160,8 +160,6 @@ namespace IRaCIS.Core.Application.ViewModel
/// 业务层级 ///
public int BusinessLevelEnum { get; set; }
- /// 邮件类型 ///
- public int EmailTypeEnum { get; set; }
/// 邮件加急类型 ///
public int EmailUrgentEnum { get; set; }
diff --git a/IRaCIS.Core.Application/Service/Document/Interface/ITrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/Interface/ITrialDocumentService.cs
index 9060e8f1a..b3fce366c 100644
--- a/IRaCIS.Core.Application/Service/Document/Interface/ITrialDocumentService.cs
+++ b/IRaCIS.Core.Application/Service/Document/Interface/ITrialDocumentService.cs
@@ -16,10 +16,10 @@ namespace IRaCIS.Core.Application.Contracts
Task UserAbandonDoc(Guid documentId, bool isSystemDoc);
Task AddOrUpdateTrialDocument(AddOrEditTrialDocument addOrEditTrialDocument);
Task DeleteTrialDocument(Guid trialDocumentId, Guid trialId);
- Task<(PageOutput, object)> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument);
+ //Task>> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument);
Task> GetTrialDocumentList(TrialDocumentQuery queryTrialDocument);
-
- Task> > GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument);
+
+ Task>> GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument);
Task SetFirstViewDocumentTime(Guid documentId, bool isSystemDoc);
Task UserConfirm(UserConfirmCommand userConfirmCommand);
Task> GetTrialUserSelect(Guid trialId);
diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs
index 8ea2c4670..cd4f3c8a0 100644
--- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs
+++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs
@@ -36,7 +36,8 @@ namespace IRaCIS.Core.Application.Services
var systemDocumentQueryable = _systemDocumentRepository.AsQueryable(true)
.WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name))
.WhereIf(inQuery.FileTypeId != null, t => t.FileTypeId == inQuery.FileTypeId)
- .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, userId = _userInfo.Id });
+ .WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted)
+ .ProjectTo(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us, userId = _userInfo.Id });
return await systemDocumentQueryable.ToPagedListAsync(inQuery);
}
diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs
index 8e13c0287..4d5f238a7 100644
--- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs
+++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs
@@ -224,8 +224,7 @@ namespace IRaCIS.Core.Application.Services
var trialInfo = await ( _trialRepository.Where(t => t.Id == inQuery.TrialId, ignoreQueryFilters: true).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync());
//系统文档查询
- var systemDocumentQueryable = from needConfirmedUserType in _systemDocNeedConfirmedUserTypeRepository.Where(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
- //.Where(u => u.UserTypeRole.UserList.SelectMany(cc => cc.UserTrials.Where(t => t.TrialId == querySystemDocument.TrialId)).Any(e => e.Trial.TrialFinishedTime < u.SystemDocument.CreateTime))
+ var systemDocumentQueryable = from needConfirmedUserType in _systemDocNeedConfirmedUserTypeRepository.Where(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId,ignoreQueryFilters:true)
.WhereIf(trialInfo.TrialFinishedTime != null, u => u.SystemDocument.CreateTime < trialInfo.TrialFinishedTime)
.WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsDeleted == false || (t.SystemDocument.IsDeleted == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
@@ -356,7 +355,7 @@ namespace IRaCIS.Core.Application.Services
///
///
[HttpPost]
- public async Task<(PageOutput, object)> GetDocumentConfirmList(DocumentTrialUnionQuery inQuery)
+ public async Task>> GetDocumentConfirmList(DocumentTrialUnionQuery inQuery)
{
@@ -393,7 +392,7 @@ namespace IRaCIS.Core.Application.Services
#endregion
- var trialInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync());
+ var trialInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId,ignoreQueryFilters:true).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync());
var trialDocQuery = from trialDocumentNeedConfirmedUserType in _trialDocNeedConfirmedUserTypeRepository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId)
join trialUser in _trialUserRepository.Where(t => t.TrialId == inQuery.TrialId)
@@ -465,7 +464,7 @@ namespace IRaCIS.Core.Application.Services
FullFilePath = needConfirmEdUserType.SystemDocument.Path
};
- var unionQuery = trialDocQuery.Union(systemDocQuery)
+ var unionQuery = trialDocQuery.Union(systemDocQuery).IgnoreQueryFilters().Where(t=>!(t.IsDeleted == true && t.ConfirmUserId == null))
.WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name))
.WhereIf(inQuery.FileTypeId != null, t => t.FileTypeId == inQuery.FileTypeId)
.WhereIf(inQuery.IsConfirmed == true, t => t.ConfirmTime != null)
@@ -486,7 +485,7 @@ namespace IRaCIS.Core.Application.Services
.CountAsync();
- return (result, new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount, TrialStatusStr = trialInfo.TrialStatusStr });
+ return ResponseOutput.Ok (result, new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount, TrialStatusStr = trialInfo.TrialStatusStr });
}
diff --git a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs
index dd74124a9..06d10cccc 100644
--- a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs
+++ b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs
@@ -27,6 +27,7 @@ using System.Runtime.InteropServices;
using SharpCompress.Common;
using DocumentFormat.OpenXml.Bibliography;
using System.Linq.Dynamic.Core;
+using Microsoft.Extensions.Options;
namespace IRaCIS.Core.Application.Service
{
@@ -50,6 +51,7 @@ namespace IRaCIS.Core.Application.Service
IRepository _subjectVisitRepository,
IRepository _readingTaskQuestionAnswerRepository,
IRepository _readingQuestionCriterionTrialRepository,
+ IOptionsMonitor _systemEmailSendConfig,
IEmailSendService _emailSendService) : BaseService, ITrialEmailNoticeConfigService
{
diff --git a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs
index f01322122..1c00c3be8 100644
--- a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs
@@ -4,6 +4,8 @@ using IRaCIS.Application.Contracts;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Models;
+using IRaCIS.Core.Domain.Share;
+using System.Globalization;
namespace IRaCIS.Core.Application.Service
{
@@ -13,10 +15,10 @@ namespace IRaCIS.Core.Application.Service
{
var userId = Guid.Empty;
- var token = string.Empty;
var isEn_Us = false;
+
CreateMap()
- .ForMember(d => d.FileType, u => u.MapFrom(s => s.FileType.Value))
+ .ForMember(d => d.FileType, u => u.MapFrom(s => isEn_Us ? s.FileType.Value: s.FileType.ValueCN))
.ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path));
CreateMap()
diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs
index 071affd3e..31f02fd6f 100644
--- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs
+++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs
@@ -382,7 +382,7 @@ namespace IRaCIS.Core.Application.Contracts
public string HtmlPath { get; set; } = string.Empty;
- public long FileSize { get; set; }
+ public long FileSize { get; set; }
}
public class CRCUploadTaskQuery
@@ -578,7 +578,7 @@ namespace IRaCIS.Core.Application.Contracts
}
- public class TrialIamgeDownQuery:PageInput
+ public class TrialIamgeDownQuery : PageInput
{
[NotDefault]
public Guid TrialId { get; set; }
@@ -595,6 +595,8 @@ namespace IRaCIS.Core.Application.Contracts
public DateTime? DownloadEndTime { get; set; }
public string? IP { get; set; }
+
+ public string? Name { get; set; }
}
public class SubjectVisitTaskInfo
diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs
index 16ec18d5e..8baae9c30 100644
--- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs
+++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs
@@ -65,8 +65,10 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
///
public async Task SubejctRandomReadingTaskNameDeal(Guid subjectId, Guid trialReadingCriterionId)
{
- //subject 随机阅片 才处理任务编号
- if (_visitTaskRepository.Any(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.SubjectRandom))
+ //subject 随机阅片 或者无序 有上传 才处理任务编号
+ if (_visitTaskRepository.Any(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId &&
+ (t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.SubjectRandom ||
+ (t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.Random && t.TrialReadingCriterion.ImageUploadEnum != ReadingImageUpload.None))))
{
//找到 非一致性分析,未签名,状态正常的 并且任务名称是TimePoint的 任务
var needDealTaskList = await _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.Id
@@ -135,7 +137,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
CriterionModalitys = u.TrialReadingCriterion.CriterionModalitys,
- SubjectCode = u.IsSelfAnalysis == true ? u.BlindSubjectCode : u.Subject.Code,
+ SubjectCode = u.IsAnalysisCreate == true ? u.BlindSubjectCode : u.Subject.Code,
TaskBlindName = u.TaskBlindName,
TaskName = u.TaskName,
@@ -183,6 +185,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
var list = await query.Where(t => t.SubjectCode == inQuery.SubjectCode).ToListAsync();
+
return ResponseOutput.Ok(list);
}
@@ -753,12 +756,18 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
[HttpPost]
public async Task> GetSubjectImageDownloadSelectList(IRReadingDownloadQuery inQuery)
{
+ //要根据标准阅片顺序,确定是否查询单个任务的,还是查询所有的
+
+ var criterionInfo= await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId)
+ .Select(t => new { t.IsReadingTaskViewInOrder }).FirstNotNullAsync();
+
+
var doctorUserId = _userInfo.Id;
var isAnalysisCreate = false;
//医学审核查看下载按钮,这个时候需要知道医生
- if (inQuery.VisitTaskId != null && inQuery.VisitTaskId != Guid.Empty)
+ if (inQuery.VisitTaskId != null )
{
var info = await _visitTaskRepository.Where(t => t.Id == inQuery.VisitTaskId).Select(t => new { t.DoctorUserId, t.IsAnalysisCreate }).FirstNotNullAsync();
@@ -768,6 +777,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
var query = _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId
&& t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect)
+ //满足 有序,或者随机只看到当前任务的dicom 非dicom检查
+ .WhereIf(criterionInfo.IsReadingTaskViewInOrder!=ReadingOrder.SubjectRandom && inQuery.VisitTaskId != null,t=>t.Id==inQuery.VisitTaskId)
.ProjectTo(_mapper.ConfigurationProvider);
//这里过滤是否是一致性分析的
@@ -837,7 +848,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
public async Task GetIRReadingDownloadStudyInfo(IRDownloadQuery inQuery)
{
var info = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId)
- .Select(t => new { t.IsImageFilter, t.CriterionModalitys, t.TrialId }).FirstNotNullAsync();
+ .Select(t => new { t.IsImageFilter, t.CriterionModalitys, t.TrialId,t.IsReadingTaskViewInOrder }).FirstNotNullAsync();
var isQueryDicom = inQuery.DicomStudyIdList.Count > 0;
var isQueryNoneDicom = inQuery.NoneDicomStudyIdList.Count > 0;
@@ -908,7 +919,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
Id = NewId.NextSequentialGuid(),
TrialId = info.TrialId,
SubjectCode = inQuery.SubjectCode,
- IP=_userInfo.IP,
+ IP = _userInfo.IP,
DownloadStartTime = DateTime.Now,
IsSuccess = false,
ImageType = imageType,
@@ -920,8 +931,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
) ?? 0
};
- await _trialImageDownloadRepository.AddAsync(preDownloadInfo,true);
- return ResponseOutput.Ok(result, preDownloadInfo.Id);
+ await _trialImageDownloadRepository.AddAsync(preDownloadInfo, true);
+
+ return ResponseOutput.Ok(result, new { PreDownloadId= preDownloadInfo.Id,info.IsReadingTaskViewInOrder } );
}
///
@@ -996,6 +1008,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
var query = _trialImageDownloadRepository.Where(t => t.TrialId == inQuery.TrialId)
.WhereIf(inQuery.SubjectCode.IsNotNullOrEmpty(), t => t.SubjectCode.Contains(inQuery.SubjectCode))
.WhereIf(inQuery.IP.IsNotNullOrEmpty(), t => t.IP.Contains(inQuery.IP))
+ .WhereIf(inQuery.Name.IsNotNullOrEmpty(), t => t.CreateUser.UserName.Contains(inQuery.Name) || t.CreateUser.FullName.Contains(inQuery.Name))
.WhereIf(inQuery.ImageType != null, t => t.ImageType == inQuery.ImageType)
.WhereIf(inQuery.UserType != null, t => t.CreateUser.UserTypeEnum == inQuery.UserType)
.WhereIf(inQuery.IsSuccess != null, t => t.IsSuccess == inQuery.IsSuccess)
diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs
index 45d2f4a3a..4615730d7 100644
--- a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs
+++ b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs
@@ -9,6 +9,7 @@ using System.ComponentModel.DataAnnotations;
using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Domain.Share;
using Medallion.Threading;
+using IRaCIS.Core.Application.Service.Reading.Dto;
namespace IRaCIS.Core.Application.Contracts
{
@@ -22,6 +23,7 @@ namespace IRaCIS.Core.Application.Contracts
IRepository _trialRepository,
IDistributedLockProvider _distributedLockProvider,
IRepository _subjectVisitRepository,
+ IRepository _visitTaskRepository,
QCCommon _qCCommon) : BaseService, INoneDicomStudyService
{
@@ -40,12 +42,16 @@ namespace IRaCIS.Core.Application.Contracts
{
noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.SubjectVisitId == subjectVisitId).WhereIf(nonedicomStudyId != null, t => t.Id == nonedicomStudyId)
- .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = isFilterZip});
+ .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = isFilterZip });
}
else
{
+ var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Select(t => new { t.BlindSubjectCode, t.TrialReadingCriterionId, t.TrialReadingCriterion.IsImageFilter, t.TrialReadingCriterion.CriterionModalitys }).FirstNotNullAsync();
+
+
noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.TaskNoneDicomFileList.Any(t => t.VisitTaskId == visitTaskId))
- .WhereIf(nonedicomStudyId != null, t => t.Id == nonedicomStudyId)
+ .Where(t => taskinfo.IsImageFilter ? ("|" + taskinfo.CriterionModalitys + "|").Contains("|" + t.Modality + "|") : true)
+ .WhereIf(nonedicomStudyId != null, t => t.Id == nonedicomStudyId)
.ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = isFilterZip, visiTaskId = visitTaskId });
}
diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/_MapConfig.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/_MapConfig.cs
index 5ba39efb7..863fa4c51 100644
--- a/IRaCIS.Core.Application/Service/ImageAndDoc/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/ImageAndDoc/_MapConfig.cs
@@ -130,7 +130,7 @@ namespace IRaCIS.Core.Application.Service
.ForMember(d => d.VisitTaskId, u => u.MapFrom(s => s.Id))
.ForMember(d => d.IsImageFilter, u => u.MapFrom(s => s.TrialReadingCriterion.IsImageFilter))
.ForMember(d => d.CriterionModalitys, u => u.MapFrom(s => s.TrialReadingCriterion.CriterionModalitys))
- .ForMember(d => d.SubjectCode, u => u.MapFrom(u => u.IsSelfAnalysis == true ? u.BlindSubjectCode : u.Subject.Code));
+ .ForMember(d => d.SubjectCode, u => u.MapFrom(u => u.IsAnalysisCreate == true ? u.BlindSubjectCode : u.Subject.Code));
CreateMap();
CreateMap();
@@ -138,7 +138,7 @@ namespace IRaCIS.Core.Application.Service
.ForMember(d => d.VisitTaskId, u => u.MapFrom(s => s.Id))
.ForMember(d => d.IsImageFilter, u => u.MapFrom(s => s.TrialReadingCriterion.IsImageFilter))
.ForMember(d => d.CriterionModalitys, u => u.MapFrom(s => s.TrialReadingCriterion.CriterionModalitys))
- .ForMember(d => d.SubjectCode, u => u.MapFrom(u => u.IsSelfAnalysis == true ? u.BlindSubjectCode : u.Subject.Code))
+ .ForMember(d => d.SubjectCode, u => u.MapFrom(u => u.IsAnalysisCreate == true ? u.BlindSubjectCode : u.Subject.Code))
.ForMember(d => d.DicomStudyList, u => u.MapFrom(s => s.SourceSubjectVisit.StudyList))
.ForMember(d => d.NoneDicomStudyList, u => u.MapFrom(s => s.SourceSubjectVisit.NoneDicomStudyList))
;
diff --git a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionViewModel.cs b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionViewModel.cs
new file mode 100644
index 000000000..858d8bd08
--- /dev/null
+++ b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionViewModel.cs
@@ -0,0 +1,73 @@
+using IRaCIS.Core.Domain.Share;
+using System.ComponentModel.DataAnnotations;
+namespace IRaCIS.Core.Application.ViewModel;
+
+public class DateDto
+{
+ public string Code { get; set; }
+
+ public string DateType { get; set; }
+
+ public string Identification { get; set; }
+}
+
+public class SetInspectionEnumValueDto
+{
+ [NotDefault]
+ public Guid TrialId { get; set; }
+
+ [NotDefault]
+ public List AuditDataIds { get; set; }
+
+
+
+}
+
+
+public class AccessToDialogueInDto
+{
+ public Guid Id { get; set; }
+
+ public AccessToDialogueEnum Type { get; set; }
+
+ public DateTime Createtime { get; set; }
+}
+
+
+public class AccessToDialogueOutDto
+{
+ public string CreateUserName { get; set; }
+
+ public string TalkContent { get; set; }
+
+ public DateTime CreateTime { get; set; }
+
+ public bool IsTitle { get; set; }
+}
+
+public enum AccessToDialogueEnum
+{
+ ///
+ ///
+ ///
+ Question = 0,
+
+ ///
+ /// һԺ˲
+ ///
+ Consistency = 1,
+}
+
+///
+///
+///
+public class CopyFrontAuditConfigItemDto
+{
+ public Guid ParentId { get; set; }
+
+ public Guid ChildId { get; set; }
+}
+
+
+
+
diff --git a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs
index e48d7d026..8f9b8b527 100644
--- a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs
+++ b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs
@@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Application.Interfaces;
using IRaCIS.Core.Application.ViewModel;
using MassTransit;
-using IRaCIS.Core.Infra.EFCore.Common.Dto;
using Microsoft.Data.SqlClient;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -19,6 +18,7 @@ using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.EntityFrameworkCore;
using Npgsql;
+using IRaCIS.Core.Infra.EFCore.Common;
namespace IRaCIS.Core.Application.Service
{
diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs
index 374d38fa8..4b885987f 100644
--- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs
+++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs
@@ -135,8 +135,8 @@ namespace IRaCIS.Core.Application.Service.Inspection
//UserLastName = leftuser.LastName,
ExperimentName = leftrial.ExperimentName,
-
- SubjectCode = leftvisttask.BlindSubjectCode.IsNullOrEmpty()? leftsubject.Code: leftvisttask.BlindSubjectCode,
+ //SubjectCode = leftvisttask.BlindSubjectCode.IsNullOrEmpty()? leftsubject.Code: leftvisttask.BlindSubjectCode,
+ SubjectCode = leftvisttask.IsAnalysisCreate? leftvisttask.BlindSubjectCode: leftsubject.Code ,
SiteCode = lefttrialSite.TrialSiteCode,
ResearchProgramNo = leftrial.ResearchProgramNo,
diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs
index 7c2b014d7..6b63943e2 100644
--- a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs
+++ b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs
@@ -32,6 +32,8 @@ namespace IRaCIS.Application.Contracts
public bool IsMFA { get; set; } = false;
+ public SystemEmailSendConfigView CompanyInfo { get; set; }
+
}
public class UserBasicInfo
diff --git a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs
index 86919aca8..89ace6dec 100644
--- a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs
@@ -66,6 +66,8 @@ namespace IRaCIS.Core.Application.Service
var result = await _userFeedBackRepository.WhereIf(inQuery.Id == null, t => t.VisitTaskId == inQuery.VisitTaskId)
.WhereIf(inQuery.VisitTaskId == null, t => t.Id == inQuery.Id).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
+
+
return ResponseOutput.Ok(result);
}
diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs
index afc1653ac..d5f865767 100644
--- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs
@@ -135,7 +135,9 @@ namespace IRaCIS.Core.Application.Service
.ForMember(d => d.SubjectVisitName, c => c.MapFrom(t => t.SubjectVisit.VisitName))
.ForMember(d => d.FeedBackUserName, c => c.MapFrom(t => t.CreateUser.UserName))
.ForMember(d => d.FeedBackFullName, c => c.MapFrom(t => t.CreateUser.FullName))
- .ForMember(d => d.UserTypeEnum, c => c.MapFrom(t => t.CreateUser.UserTypeEnum));
+ .ForMember(d => d.UserTypeEnum, c => c.MapFrom(t => t.CreateUser.UserTypeEnum))
+ .ForMember(d => d.ScreenshotList, c => c.MapFrom(t => t.FeedBackScreenshotList))
+ ;
CreateMap().ReverseMap();
}
diff --git a/IRaCIS.Core.Application/Service/QC/QCListService.cs b/IRaCIS.Core.Application/Service/QC/QCListService.cs
index eab79edba..fd8b3456c 100644
--- a/IRaCIS.Core.Application/Service/QC/QCListService.cs
+++ b/IRaCIS.Core.Application/Service/QC/QCListService.cs
@@ -62,7 +62,7 @@ namespace IRaCIS.Core.Application.Image.QA
.ProjectTo(_mapper.ConfigurationProvider);
- var defalutSortArray = new string[] { nameof(SubjectVisit.IsUrgent) + " desc", nameof(SubjectVisit.SubjectId), nameof(SubjectVisit.VisitNum) };
+ var defalutSortArray = new string[] { nameof(QCCRCVisitViewModel.IsUrgent) + " desc", nameof(QCCRCVisitViewModel.SubjectCode), nameof(QCCRCVisitViewModel.VisitNum) };
var pageList = await query.ToPagedListAsync(inQuery, defalutSortArray);
var config = await _trialRepository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException();
@@ -157,7 +157,7 @@ namespace IRaCIS.Core.Application.Image.QA
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.SubjectVisit.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id))
.ProjectTo(_mapper.ConfigurationProvider);
- var pageList = await query.ToPagedListAsync(inQuery, new string[] { "IsUrgent desc", "CreateTime asc" });
+ var pageList = await query.ToPagedListAsync(inQuery, new string[] { nameof(QCCRCChallengeViewModel.IsUrgent)+ " desc", nameof(QCCRCChallengeViewModel.CreateTime)});
var config = await _trialRepository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException();
return ResponseOutput.Ok (pageList, config);
@@ -195,7 +195,7 @@ namespace IRaCIS.Core.Application.Image.QA
.WhereIf(inQuery.IsOverTime != null && inQuery.IsOverTime == false, t => t.IsClosed ? t.ClosedTime < t.DeadlineTime : DateTime.Now < t.DeadlineTime)
.ProjectTo(_mapper.ConfigurationProvider);
- var pageList = await query.ToPagedListAsync(inQuery, new string[] { "IsUrgent desc", "IsClosed asc" });
+ var pageList = await query.ToPagedListAsync(inQuery, new string[] { nameof(QCCRCChallengeViewModel.IsUrgent) + " desc", nameof(QCCRCChallengeViewModel.CreateTime) });
var config = await _trialRepository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException();
return (pageList, config);
@@ -233,9 +233,9 @@ namespace IRaCIS.Core.Application.Image.QA
var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray);
var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId)
- .WhereIf(inQuery.VisitId != null, t => t.Id == inQuery.VisitId)
- .WhereIf(inQuery.CurrentActionUserId != null, t => t.CurrentActionUserId == inQuery.CurrentActionUserId)
- .WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState)
+ .WhereIf(inQuery.VisitId != null, t => t.Id == inQuery.VisitId)
+ .WhereIf(inQuery.CurrentActionUserId != null, t => t.CurrentActionUserId == inQuery.CurrentActionUserId)
+ .WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState)
.WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
.WhereIf(inQuery.SubjectId != null, t => t.Subject.Id == inQuery.SubjectId)
.WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => /*t.Subject.FirstName.Contains(subjectInfo) || t.Subject.LastName.Contains(subjectInfo) ||*/ t.Subject.Code.Contains(inQuery.SubjectInfo))
@@ -260,7 +260,7 @@ namespace IRaCIS.Core.Application.Image.QA
//.WhereIf(visitSearchDTO.ChallengeState != null, t => t.ChallengeState == visitSearchDTO.ChallengeState)
.ProjectTo(_mapper.ConfigurationProvider);
- var defalutSortArray = new string[] { nameof(QCVisitViewModel.IsUrgent) + " desc", nameof(QCVisitViewModel.SubjectId), nameof(QCVisitViewModel.VisitNum) };
+ var defalutSortArray = new string[] { nameof(QCVisitViewModel.IsUrgent) + " desc", nameof(QCVisitViewModel.SubjectCode), nameof(QCVisitViewModel.VisitNum) };
//var defalutSortArray = new string[] { nameof(SubjectVisit.IsUrgent) + " desc", nameof(QCVisitViewModel.AuditState) +" asc" };
var pageList = await query.ToPagedListAsync(inQuery, defalutSortArray);
@@ -638,8 +638,9 @@ namespace IRaCIS.Core.Application.Image.QA
public async Task> GetSubjectVisitSelectList(Guid subjectId)
{
- var maxNum = await _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TaskState == TaskState.Effect && t.SignTime != null && t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.InOrder).MaxAsync(x => (decimal?)x.VisitTaskNum)??0;
+ //var maxNum = await _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TaskState == TaskState.Effect && t.SignTime != null && t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.InOrder).MaxAsync(x => (decimal?)x.VisitTaskNum)??0;
+ var maxNum=await _subjectVisitRepository.Where(t=>t.SubjectId == subjectId && t.SubmitState==SubmitStateEnum.Submitted).MaxAsync(x => (decimal?)x.VisitNum) ?? 0;
return await _subjectVisitRepository.Where(t => t.SubjectId == subjectId&&t.VisitNum>= maxNum).OrderBy(T => T.VisitNum).ProjectTo(_mapper.ConfigurationProvider).ToListAsync();
}
diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs
index 7420acff1..e6b935fe5 100644
--- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs
@@ -486,11 +486,14 @@ namespace IRaCIS.Core.Application.Service
// 临床数据上传 路径拼接返回
CreateMap()
- .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token));
+ .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUser.FullName))
+ .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path ));
CreateMap()
- .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token));
+ .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUser.FullName))
+ .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path ));
CreateMap()
- .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token));
+ .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUser.FullName))
+ .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path ));
diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs
index c09cbbf25..bb6738c65 100644
--- a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs
+++ b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs
@@ -361,7 +361,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public Guid? ClinicalFormId { get; set; }
- public string PicturePath { get; set; } = string.Empty;
+ public string? PicturePath { get; set; }
public Guid SubjectId { get; set; }
diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs
index dbb1d0538..e9824555b 100644
--- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs
@@ -306,8 +306,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public decimal FristAddTaskNum { get; set; }
- public string OtherMeasureData { get; set; } = string.Empty;
- public string MeasureData { get; set; } = string.Empty;
+ public string? OtherMeasureData { get; set; }
+ public string? MeasureData { get; set; }
public List TableQuestionList { get; set; } = new List();
}
diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
index 13ff07419..596f14cf0 100644
--- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
@@ -91,7 +91,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public bool IsCanEditPosition { get; set; } = false;
- public string BlindName { get; set; } = string.Empty;
+ public string BlindName { get; set; }
public Guid? RowId { get; set; }
@@ -114,12 +114,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// 类型值
///
- public string TypeValue { get; set; }
+ public string? TypeValue { get; set; }
///
/// 序号标记
///
- public string OrderMark { get; set; } = string.Empty;
+ public string? OrderMark { get; set; }
///
/// 数值类型
@@ -129,7 +129,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// 自定义单位
///
- public string CustomUnit { get; set; } = string.Empty;
+ public string? CustomUnit { get; set; }
///
/// 单位
@@ -140,7 +140,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public ReportLayType ReportLayType { get; set; } = ReportLayType.Group;
- public string ReportMark { get; set; } = string.Empty;
+ public string? ReportMark { get; set; }
///
/// 高亮问题的答案
@@ -310,7 +310,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
{
public Guid RowId { get; set; }
- public string OrderMarkName { get; set; }
+ public string? OrderMarkName { get; set; }
public Guid? OrganInfoId { get; set; }
@@ -500,7 +500,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// MeasureData
///
- public string MeasureData { get; set; }
+ public string? MeasureData { get; set; }
///
/// CreateTime
@@ -613,7 +613,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
{
public Guid Id { get; set; }
- public string Answer { get; set; }
+ public string Answer { get; set; } = string.Empty;
}
public class DicomReadingQuestionAnswer : ReadingQuestionTrial
{
@@ -683,7 +683,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// 标记工具
///
- public string MarkTool { get; set; } = string.Empty;
+ public string? MarkTool { get; set; }
///
/// TrialId
@@ -738,7 +738,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// MeasureData
///
- public string MeasureData { get; set; } = string.Empty;
+ public string? MeasureData { get; set; }
///
/// 是否是当前任务添加
@@ -757,14 +757,14 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
public Guid? MergeRowId { get; set; }
- public string BlindName { get; set; } = string.Empty;
+ public string? BlindName { get; set; }
- public string OrderMark { get; set; } = string.Empty;
+ public string? OrderMark { get; set; }
///
/// 截图地址
///
- public string PicturePath { get; set; } = string.Empty;
+ public string? PicturePath { get; set; }
///
/// 第一次添加的任务ID
@@ -800,11 +800,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// 来自于哪个标记
///
- public string FromMark { get; set; } = string.Empty;
+ public string? FromMark { get; set; }
- public string ReportMark { get; set; } = string.Empty;
+ public string? ReportMark { get; set; }
- public string RowMark { get; set; } = string.Empty;
+ public string? RowMark { get; set; }
}
@@ -1000,13 +1000,13 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// 序号标记
///
- public string OrderMark { get; set; } = string.Empty;
+ public string? OrderMark { get; set; }
- public string OrderMarkName { get; set; } = string.Empty;
+ public string? OrderMarkName { get; set; }
- public string FromMark { get; set; } = string.Empty;
+ public string? FromMark { get; set; }
///
/// 病灶类型
@@ -1059,7 +1059,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
/// RowIndex
///
- public string RowIndex { get; set; }
+ public string? RowIndex { get; set; }
///
/// RowIndex
@@ -1072,7 +1072,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///
public bool IsDicomReading { get; set; } = true;
- public string BlindName { get; set; } = string.Empty;
+ public string? BlindName { get; set; }
///
@@ -1093,10 +1093,10 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
///