diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index ce43480c8..50a4c7090 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -1,32 +1,28 @@ { - // 日志信息 "Logging": { - // 日志等级 "LogLevel": { - // 默认日志等级 "Default": "Information", - // 调试日志等级 "Microsoft": "Warning", - // ASP.NET Core 日志等级 "Microsoft.Hosting.Lifetime": "Information" } }, - // 数据库链接字符串 "ConnectionStrings": { - // 本地数据库链接字符串 "RemoteNew": "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true", - // Hangfire 定时任务数据库链接字符串 "Hangfire": "Server=106.14.89.110,1435;Database=Test_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true" }, "WeComNoticeConfig": { "IsOpenWeComNotice": true, - "WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322 - "APINoticeUserList": [ "u", "wait..." ], - "VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ] + "WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", + "APINoticeUserList": [ + "u", + "wait..." + ], + "VueNoticeUserList": [ + "wangxiaoshuang", + "6b7717a31647293621b97b96f74e6f3d" + ] }, - // 对象存储服务配置 "ObjectStoreService": { - // 使用的对象存储服务类型 "ObjectStoreUse": "AliyunOSS", "IsOpenStoreSync": true, "ApiDeployRegion": "CN", @@ -48,168 +44,88 @@ "IsOpenSync": true } ], - // 阿里云对象存储服务的配置 "AliyunOSS": { - // 阿里云 OSS 的 Region ID "RegionId": "cn-shanghai", - // 阿里云 OSS 的内部访问端点 "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com", - // 阿里云 OSS 的外部访问端点 "EndPoint": "https://oss-cn-shanghai.aliyuncs.com", - // 阿里云 OSS 的访问密钥 ID "AccessKeyId": "LTAI5tRRZehUp2V9pyTPtAJm", - // 阿里云 OSS 的访问密钥 Secret "AccessKeySecret": "FLizxkHsMm4CGYHtkV8E3PNJJZU7oV", - // 阿里云 OSS 的角色 ARN "RoleArn": "acs:ram::1899121822495495:role/dev-oss-access", - // 阿里云 OSS 的Bucket名称 "BucketName": "zy-irc-test-store", - // 阿里云 OSS 的访问端点 "ViewEndpoint": "https://zy-irc-test-dev-cache.oss-cn-shanghai.aliyuncs.com", - // 阿里云 OSS 的预览端点 "Region": "oss-cn-shanghai", - // 阿里云 OSS 的临时访问凭证有效时间(秒) "DurationSeconds": 7200, - // 阿里云 OSS 的预览端点 "PreviewEndpoint": "https://test-oss.test.extimaging.com" }, - // MinIO 对象存储服务的配置 "MinIO": { - // MinIO 的访问端点 "EndPoint": "hir-oss.test.extimaging.com", - // MinIO 的端口 "Port": "443", - // 是否使用 SSL "UseSSL": true, - // MinIO 的角色 ARN "AccessKey": "fbStsVYCIPKHQneeqMwD", - // MinIO 的访问密钥 "SecretKey": "TzgvyA3zGXMUnpilJNUlyMYHfosl1hBMl6lxPmjy", - // MinIO 的BucketName "BucketName": "irc-test", - // MinIO 的访问端点 "ViewEndpoint": "https://hir-oss.test.extimaging.com/irc-test" }, - // AWS S3 对象存储服务的配置 "AWS": { - // AWS S3 的Region "Region": "us-east-1", - // AWS S3 的内部访问端点 "EndPoint": "s3.us-east-1.amazonaws.com", - // 是否使用 SSL "UseSSL": true, - // AWS S3 的角色 ARN "RoleArn": "arn:aws:iam::471112624751:role/uat_s3_access", - // AWS S3 的访问密钥 ID "AccessKeyId": "AKIAW3MEAFJX7IPXISP4", - // AWS S3 的访问密钥 Secret "SecretAccessKey": "Pgrg3le5jPxZQ7MR1yYNS30J0XRyJeKVyIIjElXc", - // AWS S3 的Bucket名称 "BucketName": "ei-med-s3-lili-uat-store", - // AWS S3 的访问端点 "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com", - // AWS S3 的持续数秒 "DurationSeconds": 7200 } }, - // 系统配置 "BasicSystemConfig": { - // 启用质控风险控制功能 "QCRiskControl": true, - // 打开用户复杂密码 "OpenUserComplexPassword": false, - // 是否在开始工作前强制签署电子知情同意书 "OpenSignDocumentBeforeWork": false, - // 是否启用登录失败次数限制(防暴力破解) "OpenLoginLimit": false, - // 连续登录失败多少次后触发锁定 "LoginMaxFailCount": 5, - // 触发锁定后账号锁定时长(分钟) "LoginFailLockMinutes": 1, - // 无操作自动登出的超时时间(分钟) "AutoLoginOutMinutes": 10, - // 是否启用多因子登录认证(MFA) "OpenLoginMFA": false, - // 连续阅片的最长工作时间(分钟),超时后强制休息 "ContinuousReadingTimeMin": 120, - // 强制休息时长(分钟) "ReadingRestTimeMin": 10, - // 是否强制用户定期修改密码 "IsNeedChangePassWord": true, - // 密码有效期(天),到期后必须修改 "ChangePassWordDays": 90, - // 模板类型 1 Elevate(LiLi) 2 Extensive(展影) "TemplateType": 2, - // 是否打开项目关联删除 - "OpenTrialRelationDelete": true, - // 转换PDF服务配置 + "OpenTrialRelationDelete": false, "ThirdPdfUrl": "http://106.14.89.110:30088/api/v1/convert/file/pdf", - //MFA免验证发送天数 "UserMFAVerifyMinutes": 1440 }, - // 邮件服务配置(用于系统通知、找回密码、错误报警等) "SystemEmailSendConfig": { - - // 企业邮箱SMTP服务器地址 "Host": "smtp.qiye.aliyun.com", - // SMTP端口 "Port": 465, - "Imap": "imap.qiye.aliyun.com", "ImapPort": 993, - - // 发件人邮箱地址 "FromEmail": "test@extimaging.com", - // 发件人显示名称 "FromName": "Test EIC Imaging System", - // SMTP授权码 "AuthorizationCode": "SHzyyl2021", - // 系统对外访问地址 "SiteUrl": "http://irc.test.extimaging.com/login", - - - // 系统简称 - 一致性核查使用 "SystemShortName": "IRC", - // 组织英文名称-添加用户默认值 "OrganizationName": "ExtImaging", - // 组织中文名称 "OrganizationNameCN": "ExtImaging", - "PlatformName": "EICS", "PlatformNameCN": "展影云平台", - // 公司英文全称 "CompanyName": "Extensive Imaging", - // 公司中文全称 "CompanyNameCN": "上海展影医疗科技有限公司", - // 公司英文简称 "CompanyShortName": "Extensive Imaging", - // 公司中文简称 "CompanyShortNameCN": "展影医疗", - - // 是否为国际版环境 方便前端区分,用于区分lili 还是irc 做一些事情 "IsEnv_US": false, - // 邮箱格式校验正则表达式 "EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", - - //后端周期性邮件默认语言 "CronEmailDefaultCulture": "zh-CN" }, - // PACS 连接配置 "SystemPacsConfig": { - // PACS服务器端口 "Port": "11113", - // PACS服务器IP地址 "IP": "106.14.89.110" }, - // 重复请求配置 "RequestDuplicationOptions": { - // 是否启用重复请求检测 "IsEnabled": true, - // 重复请求时间窗口(毫秒) "DuplicationWindowMs": 500, - // 缓存请求时间(秒) "CacheTimeSeconds": 5, - "ExcludedPaths": [ - ] + "ExcludedPaths": [] } -} +} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Helper/CacheHelper.cs b/IRaCIS.Core.Application/Helper/CacheHelper.cs index 5d70a0928..e326c22c4 100644 --- a/IRaCIS.Core.Application/Helper/CacheHelper.cs +++ b/IRaCIS.Core.Application/Helper/CacheHelper.cs @@ -8,6 +8,8 @@ public static class CacheKeys //项目缓存 public static string Trial(string trialIdStr) => $"TrialId:{trialIdStr}"; + public static string TrialVisitTaskMaxCode(Guid trialId) => $"TrialVisitTaskMaxCode:{trialId}"; + //检查编号递增锁 public static string TrialStudyMaxCode(Guid trialId) => $"TrialStudyMaxCode:{trialId}"; diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 6ea8aa5ab..c7b848054 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -337,6 +337,12 @@ + + + 从 NewId 的后 3 个字节(24 位)生成一个 6 位十六进制字符串 + + + 获取GetIsClinicalDataSignTest @@ -17537,17 +17543,17 @@ - ���� + 质疑 - һ���Ժ˲� + 一致性核查 - ���� + 复制 diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index 4965a065e..60851d6ed 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -439,6 +439,8 @@ namespace IRaCIS.Core.Application.ViewModel public string TaskName { get; set; } = String.Empty; + public string TaskBlindName { get; set; } = String.Empty; + public Guid? DoctorUserId { get; set; } public ReadingCategory? ReadingCategory { get; set; } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 5a48de460..0ee98e373 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -124,6 +124,45 @@ namespace IRaCIS.Core.Application.Service } + #region 获取随机编号 + /// + /// 从 NewId 的后 3 个字节(24 位)生成一个 6 位十六进制字符串 + /// + /// + public static string GenerateTaskNo() + { + var bytes = NewId.Next().ToByteArray(); + + uint value = + BitConverter.ToUInt32(bytes, 0) + ^ BitConverter.ToUInt32(bytes, 4) + ^ BitConverter.ToUInt32(bytes, 8) + ^ BitConverter.ToUInt32(bytes, 12); + + return (value & 0xFFFFFF).ToString("X6"); + } + + private async Task GetRandomTaskName(Guid trialId, List existList) + { + var taskName = GenerateTaskNo(); + + while (existList.Any(t => t == taskName)) + { + taskName = GenerateTaskNo(); + } + + while (await _visitTaskRepository.AnyAsync(t => t.TaskBlindName == taskName && t.TrialId == trialId)) + { + taskName = GenerateTaskNo(); + } + + existList.Add(taskName); + + return taskName; + } + + #endregion + //基于标准签名 产生任务 (或者手动选择某些访视生成该标准的任务) public async Task BaseCritrionGenerateVisitTask(Guid trialId, Guid confirmedTrialReadingCriterionId, bool? isManualSelectVisit = null, List? subjectVisitIdList = null) @@ -151,11 +190,11 @@ namespace IRaCIS.Core.Application.Service var dbMaxCode = _visitTaskRepository.Where(t => t.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max(); - var cacheMaxCodeInt = _fusionCache.GetOrDefault(CacheKeys.TrialStudyMaxCode(trialId)); + var cacheMaxCodeInt = _fusionCache.GetOrDefault(CacheKeys.TrialVisitTaskMaxCode(trialId)); int currentMaxCodeInt = cacheMaxCodeInt > dbMaxCode ? cacheMaxCodeInt : dbMaxCode; - + var randomTaskBlindNameList = new List(); foreach (var subjectGroup in needGenerateVisit.GroupBy(t => t.SubjectId).Select(g => new { SubjectId = g.Key, SubjectVisitList = g.ToList() })) { @@ -173,6 +212,8 @@ namespace IRaCIS.Core.Application.Service var blindTaskName = string.Empty; + var isRandom = false; + if (trialReadingCriterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder) { if (visitNumList.IndexOf(subjectVisit.VisitNum) == 0 && subjectVisit.VisitNum == 0) @@ -185,6 +226,12 @@ namespace IRaCIS.Core.Application.Service } } + else if (trialReadingCriterionConfig.IsReadingTaskViewInOrder == ReadingOrder.Random) + { + blindTaskName = await GetRandomTaskName(trialId, randomTaskBlindNameList); + + isRandom = true; + } else { blindTaskName = "Timepoint"; @@ -258,12 +305,14 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; + var blindTaskName2 = isRandom ? await GetRandomTaskName(trialId, randomTaskBlindNameList) : blindTaskName; + task2 = await _visitTaskRepository.AddAsync(new VisitTask() { TrialId = trialId, SubjectId = subjectVisit.SubjectId, IsUrgent = subjectVisit.IsUrgent, - TaskBlindName = blindTaskName, + TaskBlindName = blindTaskName2, TaskName = subjectVisit.VisitName, TaskUrgentType = taskUrgentType, IsCanEditUrgentState = isCanEditUrgentState, @@ -283,7 +332,7 @@ namespace IRaCIS.Core.Application.Service } - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); @@ -344,7 +393,7 @@ namespace IRaCIS.Core.Application.Service - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); @@ -590,11 +639,11 @@ namespace IRaCIS.Core.Application.Service var dbMaxCode = _visitTaskRepository.Where(t => t.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max(); - var cacheMaxCodeInt = _fusionCache.GetOrDefault(CacheKeys.TrialStudyMaxCode(trialId)); + var cacheMaxCodeInt = _fusionCache.GetOrDefault(CacheKeys.TrialVisitTaskMaxCode(trialId)); int currentMaxCodeInt = cacheMaxCodeInt > dbMaxCode ? cacheMaxCodeInt : dbMaxCode; - + var randomTaskBlindNameList = new List(); switch (generateTaskCommand.ReadingCategory) @@ -654,7 +703,9 @@ namespace IRaCIS.Core.Application.Service var isFrontTaskNeedSignButNotSign = await _visitTaskRepository.AnyAsync(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.TaskState == TaskState.Effect && t.VisitTaskNum < subjectVisit.VisitNum && t.IsNeedClinicalDataSign == true && t.IsClinicalDataSign == false); + var blindTaskName = string.Empty; + var isFullRandom = false; if (trialReadingCriterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder) { @@ -668,6 +719,12 @@ namespace IRaCIS.Core.Application.Service } } + else if (trialReadingCriterionConfig.IsReadingTaskViewInOrder == ReadingOrder.Random) + { + blindTaskName = await GetRandomTaskName(trialId, randomTaskBlindNameList); + isFullRandom = true; + } + //受试者随机 else { blindTaskName = "Timepoint"; @@ -721,11 +778,15 @@ namespace IRaCIS.Core.Application.Service if (!existCurrentVisitTaskList.Any(t => t.ArmEnum == Arm.DoubleReadingArm2)) { currentMaxCodeInt = currentMaxCodeInt + 1; + + var blindTaskName2 = isFullRandom ? await GetRandomTaskName(trialId, randomTaskBlindNameList) : blindTaskName; + + task2 = await _visitTaskRepository.AddAsync(new VisitTask() { TrialId = trialId, SubjectId = subjectVisit.SubjectId, - TaskBlindName = blindTaskName, + TaskBlindName = blindTaskName2, TaskName = subjectVisit.VisitName, IsUrgent = subjectVisit.IsUrgent, @@ -747,7 +808,7 @@ namespace IRaCIS.Core.Application.Service } - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); #region 分配 @@ -920,7 +981,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); } } @@ -992,7 +1053,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); } } @@ -1069,7 +1130,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); #region 分配 @@ -1197,7 +1258,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); } } @@ -1277,6 +1338,7 @@ namespace IRaCIS.Core.Application.Service var reReadingVisitTask = generateTaskCommand.ReReadingTask; + Guid? subjectVisitId = Guid.Empty; if (reReadingVisitTask.SourceSubjectVisitId == null) @@ -1317,6 +1379,10 @@ namespace IRaCIS.Core.Application.Service //&& t.TrialReadingCriterionId == reReadingVisitTask.TrialReadingCriterionId && t.TaskState == TaskState.Effect // && t.SourceSubjectVisitId == reReadingVisitTask.SourceSubjectVisitId && t.ArmEnum == reReadingVisitTask.ArmEnum && t.DoctorUserId == reReadingVisitTask.DoctorUserId).FirstOrDefault(); + var isRandomReading = trialReadingCriterionConfigList.FirstOrDefault(t => t.TrialReadingCriterionId == reReadingVisitTask.TrialReadingCriterionId)?.IsReadingTaskViewInOrder == ReadingOrder.Random; + + var taskBlindName = isRandomReading ? await GetRandomTaskName(trialId, randomTaskBlindNameList) : reReadingVisitTask.TaskBlindName; + var newTask = await _visitTaskRepository.AddAsync(new VisitTask() { @@ -1325,7 +1391,7 @@ namespace IRaCIS.Core.Application.Service SubjectId = reReadingVisitTask.SubjectId, ArmEnum = reReadingVisitTask.ArmEnum, TaskName = reReadingVisitTask.TaskName, - TaskBlindName = reReadingVisitTask.TaskBlindName, + TaskBlindName = taskBlindName, IsUrgent = reReadingVisitTask.IsAnalysisCreate ? false : subjectVisitUrgentInfo.IsUrgent, TaskUrgentType = reReadingVisitTask.IsAnalysisCreate ? null : taskUrgent, @@ -1386,7 +1452,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); //} @@ -1491,7 +1557,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); } break; @@ -1538,7 +1604,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); } break; @@ -1548,6 +1614,11 @@ namespace IRaCIS.Core.Application.Service var subjectUser = await _subjectUserRepository.Where(x => x.SubjectId == firstTask.SubjectId && x.ArmEnum == Arm.JudgeArm && x.IsConfirmed && x.TrialReadingCriterionId == firstTask.TrialReadingCriterionId).FirstOrDefaultAsync(); + + var isRandom = trialReadingCriterionConfigList.FirstOrDefault(t => t.TrialReadingCriterionId == firstTask.TrialReadingCriterionId)?.IsReadingTaskViewInOrder == ReadingOrder.Random; + + var blindName = isRandom ? await GetRandomTaskName(trialId, randomTaskBlindNameList) : firstTask.TaskBlindName; + VisitTask visitTask = new VisitTask() { ArmEnum = Arm.JudgeArm, @@ -1564,7 +1635,7 @@ namespace IRaCIS.Core.Application.Service SouceReadModuleId = firstTask.SouceReadModuleId, TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), TaskState = TaskState.Effect, - TaskBlindName = firstTask.TaskBlindName, + TaskBlindName = blindName, DoctorUserId = subjectUser == null ? null : subjectUser.DoctorUserId, TaskAllocationState = subjectUser == null ? TaskAllocationState.NotAllocate : TaskAllocationState.Allocated, AllocateTime = subjectUser == null ? null : DateTime.Now, @@ -1576,7 +1647,7 @@ namespace IRaCIS.Core.Application.Service await _visitTaskRepository.AddAsync(visitTask); currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => generateTaskCommand.JudgeVisitTaskIdList.Contains(x.Id), x => new VisitTask() { @@ -1637,7 +1708,7 @@ namespace IRaCIS.Core.Application.Service }); currentMaxCodeInt = currentMaxCodeInt + 1; - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); } } @@ -1707,7 +1778,7 @@ namespace IRaCIS.Core.Application.Service TrialId = originalTaskInfo.TrialId }); - _fusionCache.Set(CacheKeys.TrialStudyMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _fusionCache.Set(CacheKeys.TrialVisitTaskMaxCode(trialId), currentMaxCodeInt, TimeSpan.FromMinutes(30)); } break; } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 09891cf59..5d6242dad 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -854,7 +854,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, /// /// [HttpPost] - public async Task> GetIRReReadingTaskList(VisitTaskQuery inQuery) + public async Task>> GetIRReReadingTaskList(VisitTaskQuery inQuery) { var visitTaskQueryable = _visitTaskReReadingRepository @@ -878,6 +878,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, .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.TaskBlindName), t => t.NewReReadingTask.TaskBlindName.Contains(inQuery.TaskBlindName)) .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)) @@ -889,7 +890,11 @@ public class VisitTaskService(IRepository _visitTaskRepository, var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray); - return pageList; + var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId) + .Select(t => new { t.IsReadingTaskViewInOrder }).FirstNotNullAsync(); + + return ResponseOutput.Ok(pageList, criterionInfo); + } @@ -1242,7 +1247,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, /// /// [HttpPost] - public async Task> GetIRHaveReadTaskList(VisitTaskQuery inQuery) + public async Task>> GetIRHaveReadTaskList(VisitTaskQuery inQuery) { @@ -1261,6 +1266,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, .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.TaskBlindName), t => t.TaskBlindName.Contains(inQuery.TaskBlindName)) .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)) @@ -1270,7 +1276,10 @@ public class VisitTaskService(IRepository _visitTaskRepository, var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery, defalutSortArray); - return pageList; + var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId) + .Select(t => new { t.IsReadingTaskViewInOrder }).FirstNotNullAsync(); + + return ResponseOutput.Ok(pageList, criterionInfo); } @@ -2267,7 +2276,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, _ = _taskSeriesRepository.AddAsync(newSeries).Result; - var studyInstanceList = taskInstanceList.Where(t => t.StudyId == taskStudy.Id).ToList(); + var studyInstanceList = taskInstanceList.Where(t => t.StudyId == taskStudy.Id && t.SeriesId == series.Id).ToList(); foreach (var instance in studyInstanceList) { diff --git a/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs b/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs index e9634987e..28f875901 100644 --- a/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs @@ -4,6 +4,7 @@ using Medallion.Threading; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; @@ -16,7 +17,7 @@ using System.Threading.Tasks; namespace IRaCIS.Core.Application.Service.Common; [ApiExplorerSettings(GroupName = "Common")] -public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _distributedLockProvider, IUserInfo _userInfo, IWebHostEnvironment _hostEnvironment, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService +public class DeployConfigService(IMapper _mapper, IConfiguration _configuration, IDistributedLockProvider _distributedLockProvider, IUserInfo _userInfo, IWebHostEnvironment _hostEnvironment, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService { /// @@ -26,7 +27,18 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist /// public async Task GetSystemBasicConfigInfo([FromServices] IOptionsMonitor options) { - return options.CurrentValue; + //var config = _configuration.GetSection("BasicSystemConfig").Get(); + //return config; + + + var path = Path.Combine( _hostEnvironment.ContentRootPath,$"appsettings.{_hostEnvironment.EnvironmentName}.json"); + + var json = File.ReadAllText(path); + + var obj = JObject.Parse(json); + + return obj["BasicSystemConfig"]!.ToObject()!; + } /// @@ -37,7 +49,8 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist [HttpPost] public async Task UpdateSystemBasicConfig(ServiceVerifyConfigOption basicSystemConfigOption) { - var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; + //var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); var @lock = _distributedLockProvider.CreateLock("WriteConfigFile"); @@ -73,6 +86,7 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist // 重新写入appsettings.json string result = obj.ToString(); System.IO.File.WriteAllText(path, result); + } @@ -86,7 +100,18 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist /// public async Task GetEmailConfigInfo([FromServices] IOptionsMonitor options) { - return options.CurrentValue; + //两种方式都有问题 + //var config = _configuration.GetSection("BasicSystemConfig").Get(); + //return config; + //return options.CurrentValue; + + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); + + var json = File.ReadAllText(path); + + var obj = JObject.Parse(json); + + return obj["SystemEmailSendConfig"]!.ToObject()!; } @@ -98,7 +123,8 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist [HttpPost] public async Task UpdateSystemEmailConfig(SystemEmailSendConfig emailConfig) { - var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; + var path = Path.Combine(_hostEnvironment.ContentRootPath,$"appsettings.{_hostEnvironment.EnvironmentName}.json"); + //var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; var @lock = _distributedLockProvider.CreateLock("WriteConfigFile"); @@ -139,6 +165,7 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist string result = obj.ToString(); System.IO.File.WriteAllText(path, result); + } return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index a08d0240f..7bb6f15f3 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -58,8 +58,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc { //subject 随机阅片 或者无序 有上传 才处理任务编号 if (_visitTaskRepository.Any(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && - (t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.SubjectRandom || - (t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.Random && t.TrialReadingCriterion.ImageDownloadEnum != ReadingImageDownload.None)))) + (t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.SubjectRandom + //||(t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.Random && t.TrialReadingCriterion.ImageDownloadEnum != ReadingImageDownload.None) + ))) { //找到 非一致性分析,未签名,状态正常的 并且任务名称是TimePoint的 任务 var needDealTaskList = await _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.DoctorUserId == _userInfo.UserRoleId diff --git a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs index ccf72d147..03bd134b2 100644 --- a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs @@ -246,9 +246,9 @@ namespace IRaCIS.Core.Application.Service var visitTaskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => taskIds.Contains(x.VisitTaskId) && x.ReadingQuestionTrial.IsJudgeQuestion).Select(x => new JudgeQuestionAnswerInfo { Answer = x.Answer, - Unit=x.ReadingQuestionTrial.Unit, - ValueType=x.ReadingQuestionTrial.ValueType, - CustomUnit=x.ReadingQuestionTrial.CustomUnit, + Unit = x.ReadingQuestionTrial.Unit, + ValueType = x.ReadingQuestionTrial.ValueType, + CustomUnit = x.ReadingQuestionTrial.CustomUnit, VisitTaskId = x.VisitTaskId, DictionaryCode = x.ReadingQuestionTrial.DictionaryCode, ShowOrder = x.ReadingQuestionTrial.ShowOrder, @@ -643,8 +643,8 @@ namespace IRaCIS.Core.Application.Service [HttpPost] public async Task TestGetJointMedicalReviewDialog(Guid id) { - var dialog = await _readingMedicalReviewDialogRepository.Where(x => x.Id == id) - .ProjectTo(_mapper.ConfigurationProvider).FirstNotNullAsync(); + var dialog = await _readingMedicalReviewDialogRepository.Where(x => x.Id == id) + .ProjectTo(_mapper.ConfigurationProvider).FirstNotNullAsync(); Dictionary i18NKeys = new Dictionary() @@ -661,11 +661,11 @@ namespace IRaCIS.Core.Application.Service }; var i18Values = i18NKeys.Select(x => x.Value).ToList(); - var i18nList=await _internationalizationRepository.Where(x => i18Values.Contains(x.Code)) - .Select(x => new + var i18nList = await _internationalizationRepository.Where(x => i18Values.Contains(x.Code)) + .Select(x => new { - Code= x.Code, - Value= _userInfo.IsEn_Us?x.Value:x.ValueCN + Code = x.Code, + Value = _userInfo.IsEn_Us ? x.Value : x.ValueCN }).ToListAsync(); List dictionaryCodeList = new List() @@ -676,16 +676,16 @@ namespace IRaCIS.Core.Application.Service "YesOrNo", }; - var dictionadParents=await _dictionaryRepository.Where(x=> dictionaryCodeList.Contains(x.Parent.Code)) + var dictionadParents = await _dictionaryRepository.Where(x => dictionaryCodeList.Contains(x.Parent.Code)) .Select(x => new { ParentCode = x.Parent.Code, - Code=x.Code, + Code = x.Code, Value = _userInfo.IsEn_Us ? x.Value : x.ValueCN }).ToListAsync(); JointMedicalReviewI18n i18N = new JointMedicalReviewI18n() { }; - foreach (var kv in i18NKeys) + foreach (var kv in i18NKeys) { PropertyInfo? pi = i18N.GetType().GetProperty(kv.Key); if (pi != null && pi.CanWrite) @@ -706,7 +706,7 @@ namespace IRaCIS.Core.Application.Service } } - return await JointMedicalReviewDialog(dialog,i18N); + return await JointMedicalReviewDialog(dialog, i18N); @@ -910,7 +910,7 @@ namespace IRaCIS.Core.Application.Service [HttpPost] public async Task GetNextIRMedicalFeedback(GetNextIRMedicalFeedbackInDto inDto) { - var list = await GetIRMedicalFeedbackList(new GetIRMedicalFeedbackListInDto() + var responseOutput = await GetIRMedicalFeedbackList(new GetIRMedicalFeedbackListInDto() { TrialId = inDto.TrialId, TrialReadingCriterionId = inDto.TrialReadingCriterionId, @@ -919,6 +919,8 @@ namespace IRaCIS.Core.Application.Service PageSize = 99999, }); + var list = responseOutput.Data; + var index = list.CurrentPageData.ToList().FindIndex(x => x.Id == inDto.TaskMedicalReviewId); var result = new GetIRMedicalFeedbackListOutDto() { }; @@ -949,12 +951,12 @@ namespace IRaCIS.Core.Application.Service /// /// [HttpPost] - public async Task> GetIRMedicalFeedbackList(GetIRMedicalFeedbackListInDto inDto) + public async Task>> GetIRMedicalFeedbackList(GetIRMedicalFeedbackListInDto inDto) { var taskMedicalReviewquery = _taskMedicalReviewRepository.Where(x => x.TrialId == inDto.TrialId).Include(x => x.VisitTask) .Where(x => x.VisitTask.DoctorUserId == _userInfo.UserRoleId) .Where(x => x.IsHaveQuestion) - .WhereIf(!inDto.TaskBlindName.IsNullOrEmpty(), x => x.VisitTask.TaskBlindName == inDto.TaskBlindName) + .WhereIf(!inDto.TaskBlindName.IsNullOrEmpty(), x => x.VisitTask.TaskBlindName.Contains(inDto.TaskBlindName)) .WhereIf(inDto.SubjectId != null, x => x.VisitTask.SubjectId == inDto.SubjectId!) .WhereIf(inDto.IsUrgent != null, x => x.VisitTask.IsUrgent == inDto.IsUrgent!) .WhereIf(inDto.AuditState != null, x => x.AuditState == inDto.AuditState!) @@ -1004,7 +1006,11 @@ namespace IRaCIS.Core.Application.Service var result = await taskMedicalReviewquery.ToPagedListAsync(inDto, nameof(GetIRMedicalFeedbackListOutDto.AuditState)); - return result; + var criterionInfo = await _readingQuestionCriterionTrial.Where(t => t.Id == inDto.TrialReadingCriterionId) + .Select(t => new { t.IsReadingTaskViewInOrder }).FirstNotNullAsync(); + + return ResponseOutput.Ok(result, criterionInfo); + } } } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index d3d722b04..4d27ac9aa 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -920,7 +920,7 @@ namespace IRaCIS.Core.Application.Contracts var trialType = _trialRepository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault(); - foreach (var item in needGenerateList.GroupBy(t => t.Email)) + foreach (var item in needSendEmailList.GroupBy(t => t.Email)) { var addUserRoleList = item.ToList(); @@ -1137,23 +1137,26 @@ namespace IRaCIS.Core.Application.Contracts await _trialSiteUserSurveyRepository.UpdatePartialFromQueryAsync(t => userJoinIdList.Contains(t.Id), u => new TrialSiteUserSurvey() { IsJoin = true, SystemUserId = existSysUser.Id }); - //中心调研设置用户角色退出 - var needQuitUserList = item.Where(t => t.IsHistoryUser && t.IsHistoryUserOriginDeleted == false && t.IsHistoryUserDeleted == true).ToList(); - - var queitUserTypeIdList = needQuitUserList.Select(t => t.UserTypeId).ToList(); - - - await _trialSiteUserRoleRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId && queitUserTypeIdList.Contains(t.UserRole.UserTypeId), c => new TrialSiteUserRole() - { - IsDeleted = true, - DeletedTime = DateTime.Now, - }); - + await _trialSiteUserRoleRepository.SaveChangesAsync(); } + + //中心调研设置用户角色退出 + var needQuitUserList = allUserList.Where(t => t.IsHistoryUser && t.IsHistoryUserOriginDeleted == false && t.IsHistoryUserDeleted == true).ToList(); + + var queitUserTypeIdList = needQuitUserList.Select(t => t.UserTypeId).ToList(); + + + await _trialSiteUserRoleRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId && queitUserTypeIdList.Contains(t.UserRole.UserTypeId), c => new TrialSiteUserRole() + { + IsDeleted = true, + DeletedTime = DateTime.Now, + }); + + await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.UserRoleId, ReviewerTime = DateTime.Now }); }