From 6f1a0f14a53bf7efedf7049dda9aa7432e6dc4a4 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 3 Mar 2023 10:18:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=B1=E5=83=8F?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Allocation/VisitTaskHelpeService.cs | 2 +- .../Document/TrialEmailNoticeConfigService.cs | 2 +- .../Service/ImageAndDoc/DicomArchiveService.cs | 17 ++++++++++++++--- .../Service/ImageAndDoc/StudyService.cs | 2 +- .../Service/QC/QCOperationService.cs | 2 +- IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs | 7 +------ IRaCIS.Core.Domain/SQLFile/Test.sql | 8 +++++++- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 0e87a6845..ac8dcabbd 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -92,7 +92,7 @@ namespace IRaCIS.Core.Application.Service { //找到一致性核查通过且没有产生任务的访视 var needGenerateVisit = await _subjectVisitRepository.Where(t => t.TrialId == trialId && t.CheckState == CheckStateEnum.CVPassed && - !t.VisitTaskList.Any(u => u.TrialReadingCriterionId == confirmedTrialReadingCriterionId && u.SourceSubjectVisitId == t.Id)).ToListAsync(); + !t.VisitTaskList.Any(u => u.TrialReadingCriterionId == confirmedTrialReadingCriterionId && u.SourceSubjectVisitId == t.Id && u.TaskState==TaskState.Effect && u.IsAnalysisCreate==false)).ToListAsync(); var trialReadingCriterionConfig = await _trialReadingCriterionRepository.Where(t => t.Id == confirmedTrialReadingCriterionId).Select(t => new { TrialReadingCriterionId = t.Id, t.ReadingTool, t.ReadingType, t.IsReadingTaskViewInOrder, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign, t.FollowGlobalVisitAutoAssignDefaultState, t.FollowVisitAutoAssignDefaultState, t.TaskAllocateObjEnum, t.CriterionType }).FirstOrDefaultAsync(); diff --git a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs index 73ae4175a..13f549d9d 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs @@ -785,7 +785,7 @@ namespace IRaCIS.Core.Application.Service ["TrialSiteCode"] = taskInfo.TrialSiteCode, ["SubjectCode"] = taskInfo.SubjectCode, ["VisitName"] = taskInfo.SourceSubjectVisitId != null ? taskInfo.VisitName : taskInfo.ModuleVisitName, - ["EarliestScanDate"] = taskInfo.SourceSubjectVisitId != null ? taskInfo.VisitEarliestScanDate : taskInfo.ModuleEarliestScanDate, + ["EarliestScanDate"] = taskInfo.SourceSubjectVisitId != null ? taskInfo.VisitEarliestScanDate?.ToString("yyyy-MM-DD") : taskInfo.ModuleEarliestScanDate?.ToString("yyyy-MM-DD"), ["SignTime"] = taskInfo.SignTime, ["Result"] = answer diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs index f852be365..9864b1c07 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs @@ -162,21 +162,32 @@ namespace IRaCIS.Core.Application.Services var samplesPerPixel = dataset.GetSingleValueOrDefault(DicomTag.SamplesPerPixel, string.Empty); var photometricInterpretation = dataset.GetSingleValueOrDefault(DicomTag.PhotometricInterpretation, string.Empty); + if (samplesPerPixel == "1" && (photometricInterpretation.ToUpper() == "MONOCHROME2" || photometricInterpretation.ToUpper() == "MONOCHROME1"))//MONOCHROME2 { if (dataset.InternalTransferSyntax.IsEncapsulated) { + //正常保存 不做处理 await dicomFile.SaveAsync(physicalPath); } else - { + { //JPEGLSLossless 保存 await dicomFile.Clone(DicomTransferSyntax.JPEGLSLossless).SaveAsync(physicalPath); } } else { - if (dataset.InternalTransferSyntax.IsEncapsulated) await dicomFile.SaveAsync(physicalPath); - else await dicomFile.Clone(DicomTransferSyntax.RLELossless).SaveAsync(physicalPath); //RLELossless + if (dataset.InternalTransferSyntax.IsEncapsulated) + { + //正常保存 不做处理 + await dicomFile.SaveAsync(physicalPath); + } + else + { + //RLELossless 保存 + await dicomFile.Clone(DicomTransferSyntax.RLELossless).SaveAsync(physicalPath); //RLELossless + + } } return (dicomInstance.StudyId, dicomStudy.StudyCode); } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index 647d5a2c5..48e5f0faf 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -151,7 +151,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc public async Task> GetDicomAndNoneDicomStudyMonitorList(StudyQuery studyQuery) { var svExpression = QCCommon.GetStudyMonitorSubjectVisitFilter(studyQuery.VisitPlanArray); - var StudyMonitorQuery = _repository.Where(t => t.TrialId == studyQuery.TrialId) + var StudyMonitorQuery = _repository.Where(t => t.TrialId == studyQuery.TrialId,ignoreQueryFilters:true) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) //.WhereIf(!string.IsNullOrEmpty(studyQuery.VisitPlanInfo), studyQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.VisitNum.ToString().Contains(".") : t => t.SubjectVisit.VisitNum == decimal.Parse(studyQuery.VisitPlanInfo)) .WhereIf(studyQuery.VisitPlanArray != null && studyQuery.VisitPlanArray?.Length > 0, svExpression) diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 40b077555..7bc62844b 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -792,7 +792,7 @@ namespace IRaCIS.Core.Application.Image.QA var success3 = await _dicomSeriesrepository.BatchDeleteNoTrackingAsync(t => t.StudyId == id); //var success3 = await _dicomSeriesrepository.DeleteFromQueryAsync(t => t.StudyId == id, true); - var success4 = await _repository.BatchDeleteAsync(t => t.StudyId == id); + //var success4 = await _repository.BatchDeleteAsync(t => t.StudyId == id); //删除 物理文件 diff --git a/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs b/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs index 9d6a6579f..39d940765 100644 --- a/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs +++ b/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs @@ -25,15 +25,10 @@ namespace IRaCIS.Core.Domain.Models public Guid CreateUserId { get; set; } - //可能是Dicom 也可能是非Dicom + //可能是Dicom 也可能是非Dicom 该字段废弃 public Guid StudyId { get; set; } - - - //public int TotalMillisecondsInterval { get; set; } - - public DateTime UploadStartTime { get; set; } diff --git a/IRaCIS.Core.Domain/SQLFile/Test.sql b/IRaCIS.Core.Domain/SQLFile/Test.sql index 9de49ae3a..e9d8650a9 100644 --- a/IRaCIS.Core.Domain/SQLFile/Test.sql +++ b/IRaCIS.Core.Domain/SQLFile/Test.sql @@ -956,4 +956,10 @@ where ReadingQuestionTrial.ReadingQuestionSystemId is not null and ReadingTableQ update CommonDocument set Name='PD进展报告.docx' where Name='PCR_v1.0_Final.docx' update CommonDocument set Name='入组确认报告.docx' where Name='ECR_v1.0_Final.docx' update TrialEmailNoticeConfig set FileName='PD进展报告.docx' where FileName='PCR_v1.0_Final.docx' -update TrialEmailNoticeConfig set FileName='入组确认报告.docx' where FileName='ECR_v1.0_Final.docx' \ No newline at end of file +update TrialEmailNoticeConfig set FileName='入组确认报告.docx' where FileName='ECR_v1.0_Final.docx' + + + +-- 出现质疑未关闭 但是实际所有质疑都关闭了(不存在 未关闭的质疑) +select * from SubjectVisit where ChallengeState=2 and not EXISTS(select * from QCChallenge where SubjectVisitId=SubjectVisit.Id and IsClosed=0) +update SubjectVisit set ChallengeState=1 where ChallengeState=2 and not EXISTS(select * from QCChallenge where SubjectVisitId=SubjectVisit.Id and IsClosed=0) \ No newline at end of file From cfb6ba593b08a1f785735d7ba905627abe95e5a9 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 3 Mar 2023 13:43:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Helper/FileStoreHelper.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs index e64c16be1..782681014 100644 --- a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs @@ -3,6 +3,7 @@ using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; using Microsoft.AspNetCore.Hosting; +using System.Text.RegularExpressions; namespace IRaCIS.Core.Application.Helper; @@ -25,6 +26,14 @@ public static class FileStoreHelper fileName = fileName.Split("/").Last(); } + var matchResult = Regex.Match(fileName, @"[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}"); + + //如果有guid + if (matchResult.Success) + { + fileName = fileName.Replace($"{matchResult.Value}", ""); + } + var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileName; return (trustedFileNameForFileStorage, fileName); From 372fa13239dfd6ad771bba5a420dabf21248ab1c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 3 Mar 2023 15:06:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=92=8C=E7=A8=BD=E6=9F=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Helper/SendEmailHelper.cs | 25 +++++++++++++------ .../Service/QC/QCOperationService.cs | 2 +- .../Common/AuditingData.cs | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/Helper/SendEmailHelper.cs b/IRaCIS.Core.Application/Helper/SendEmailHelper.cs index aa5ee76b2..45a129e77 100644 --- a/IRaCIS.Core.Application/Helper/SendEmailHelper.cs +++ b/IRaCIS.Core.Application/Helper/SendEmailHelper.cs @@ -1,7 +1,9 @@ -using IRaCIS.Core.Domain.Share; +using DocumentFormat.OpenXml.Spreadsheet; +using IRaCIS.Core.Domain.Share; using MailKit; using MailKit.Security; using MimeKit; +using NPOI.HPSF; namespace IRaCIS.Core.Application.Helper; @@ -40,10 +42,10 @@ public static class SendEmailHelper catch (Exception ex) { - throw new Exception("邮件发送失败,您进行的操作未能成功,请检查邮箱或联系维护人员") ; + throw new Exception("邮件发送失败,您进行的操作未能成功,请检查邮箱或联系维护人员"); } - + } public static async Task SendEmailAsync(SMTPEmailConfig sMTPEmailConfig, EventHandler? messageSentSuccess = null) @@ -88,10 +90,19 @@ public static class SendEmailHelper { //builder.Attachments.Add(item.FileName, item.FileData); - builder.Attachments.Add(item.FileName, item.FileStream); + var attachment = builder.Attachments.Add(item.FileName, item.FileStream); + + //解决附件名过长 奇怪的名字 + foreach (var param in attachment.ContentDisposition.Parameters) + param.EncodingMethod = ParameterEncodingMethod.Rfc2047; + foreach (var param in attachment.ContentType.Parameters) + param.EncodingMethod = ParameterEncodingMethod.Rfc2047; + } + + messageToSend.Body = builder.ToMessageBody(); using (var smtp = new MailKit.Net.Smtp.SmtpClient()) @@ -113,7 +124,7 @@ public static class SendEmailHelper await smtp.DisconnectAsync(true); } - + } } @@ -123,12 +134,12 @@ public static class SendEmailHelper public class SMTPEmailConfig { - public int Port { get; set; } + public int Port { get; set; } public string Host { get; set; } - public string UserName { get; set; } + public string UserName { get; set; } public string AuthorizationCode { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 7bc62844b..a9636aed2 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -1195,7 +1195,7 @@ namespace IRaCIS.Core.Application.Image.QA // CRC 上传的基线数据签名 - await _readingClinicalDataRepository.BatchUpdateNoTrackingAsync(x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC && x.ReadingId == dbSubjectVisit.Id, x => new ReadingClinicalData() + await _readingClinicalDataRepository.UpdatePartialFromQueryAsync(x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC && x.ReadingId == dbSubjectVisit.Id && x.IsSign==false, x => new ReadingClinicalData() { IsSign = true, ReadingClinicalDataState = ReadingClinicalDataStatus.HaveSigned diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 7ab3f8a3b..905af45ab 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -1696,7 +1696,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common IsDistinctionInterface = type == AuditOpt.Update ? true : false, - //SubjectVisitId = x.IsVisit ? x.ReadingId : null, + SubjectVisitId = x.IsVisit ? x.ReadingId : null, ObjectRelationParentId = entity.ClinicalDataTrialSetId,