From a76cc7a6d69b953fedb2143ef8a3403464e606c5 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Mon, 30 May 2022 18:25:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UploadDownLoadController.cs | 27 +++++++++++++++++++ .../Helper/FileStoreHelper.cs | 21 +++++++++++++++ .../QC/ClinicalData/PreviousPDF.cs | 9 +++++-- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index 3bb2f502a..edea38c2a 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -396,6 +396,33 @@ namespace IRaCIS.Core.API.Controllers } + /// + /// 上传临床数据 + /// + /// + /// + [HttpPost("ClinicalData/UploadClinicalData/{trialId:guid}/{clinicalDataId:guid}")] + [DisableRequestSizeLimit] + public async Task UploadClinicalData(Guid clinicalDataId) + { + + var sv = _repository.Where(t => t.Id == clinicalDataId).Select(t => new { t.TrialId, t.SubjectId }).FirstOrDefault().IfNullThrowException(); + await FileUploadAsync(async (fileName) => + { + var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, sv.TrialId.Value, sv.SubjectId.Value, clinicalDataId); + + //插入临床pdf 路径 + await _repository.AddAsync(new PreviousPDF() { SubjectVisitId = clinicalDataId, Path = relativePath, FileName = fileRealName }); + + return serverFilePath; + }); + + await _repository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + } + + /// /// 上传非Dicom 文件 支持压缩包 多文件上传 diff --git a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs index 6f3e59834..e1467fb5a 100644 --- a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs @@ -230,6 +230,27 @@ public static class FileStoreHelper } + + public static (string PhysicalPath, string RelativePath, string FileRealName) GetClinicalDataPath(IWebHostEnvironment _hostEnvironment, string fileName, Guid trialId , Guid subjectId, Guid clinicalDataId) + { + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); + + string uploadFolderPath = Path.Combine(rootPath, StaticData.Folder.TrialDataFolder, trialId.ToString(), subjectId.ToString(), clinicalDataId.ToString(), StaticData.Folder.TreatmenthistoryFolder); + + if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath); + + var (trustedFileNameForFileStorage, fileRealName) = FileStoreHelper.GetStoreFileName(fileName); + + + var relativePath = $"/{StaticData.Folder.IRaCISDataFolder}/{StaticData.Folder.TrialDataFolder}/{trialId}/{subjectId}/{clinicalDataId}/{StaticData.Folder.TreatmenthistoryFolder}/{trustedFileNameForFileStorage}"; + + var serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage); + + return (serverFilePath, relativePath, fileRealName); + + } + + //获取非dicom文件存放路径 public static (string PhysicalPath, string RelativePath, string FileRealName) GetNoneDicomFilePath(IWebHostEnvironment _hostEnvironment, string fileName, Guid trialId, Guid siteId, Guid subjectId, Guid subjectVisitId) { diff --git a/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs b/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs index f14f2f076..cf3a175f6 100644 --- a/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs +++ b/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs @@ -46,8 +46,13 @@ namespace IRaCIS.Core.Domain.Models /// [Required] public Guid CreateUserId { get; set; } - - } + + /// + /// 临床数据ID + /// + public Guid? ClinicalDataId { get; set; } + + } }