修改一版
This commit is contained in:
@@ -13,10 +13,12 @@ using IRaCIS.Core.Application.MediatR.CommandAndQueries;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Domain.Share.Reading;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Magicodes.ExporterAndImporter.Excel;
|
||||
using MassTransit;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -206,16 +208,19 @@ namespace IRaCIS.Core.API.Controllers
|
||||
public IMapper _mapper { get; set; }
|
||||
public IUserInfo _userInfo { get; set; }
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
private readonly IRepository<ClinicalData> _clinicalDataRepository;
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
|
||||
private readonly IRepository _repository;
|
||||
|
||||
|
||||
public StudyController(IMapper mapper, IUserInfo userInfo, IWebHostEnvironment hostEnvironment, IMediator mediator,IRepository repository)
|
||||
public StudyController(IMapper mapper, IUserInfo userInfo, IWebHostEnvironment hostEnvironment, IMediator mediator,
|
||||
IRepository<ClinicalData> clinicalDataRepository,
|
||||
IRepository repository)
|
||||
{
|
||||
_hostEnvironment = hostEnvironment;
|
||||
_mediator = mediator;
|
||||
this._clinicalDataRepository = clinicalDataRepository;
|
||||
_mapper = mapper;
|
||||
_userInfo = userInfo;
|
||||
_repository = repository;
|
||||
@@ -375,44 +380,55 @@ namespace IRaCIS.Core.API.Controllers
|
||||
public async Task<IResponseOutput> UploadVisitClinicalData(Guid subjectVisitId)
|
||||
{
|
||||
await QCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId);
|
||||
|
||||
var sv = _repository.Where<SubjectVisit>(t => t.Id == subjectVisitId).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefault().IfNullThrowException();
|
||||
|
||||
|
||||
ClinicalData? clinical = await _clinicalDataRepository.Where(x => x.VisitOrReadId == subjectVisitId && x.ClinicalLevel == ClinicalLevel.Subject).FirstOrDefaultAsync();
|
||||
if (clinical == null)
|
||||
{
|
||||
clinical = new ClinicalData()
|
||||
{
|
||||
ClinicalLevel = ClinicalLevel.Subject,
|
||||
SubjectId = sv.SubjectId,
|
||||
DataType = ClinicalDataType.MedicalHistory,
|
||||
TrialId = sv.TrialId,
|
||||
UploadType = ClinicalUploadType.PDF,
|
||||
VisitOrReadId = subjectVisitId,
|
||||
Id= NewId.NextGuid(),
|
||||
};
|
||||
|
||||
await _clinicalDataRepository.AddAsync(clinical);
|
||||
|
||||
}
|
||||
await FileUploadAsync(async (fileName) =>
|
||||
{
|
||||
var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, sv.TrialId, sv.SiteId, sv.SubjectId, subjectVisitId);
|
||||
|
||||
//插入临床pdf 路径
|
||||
await _repository.AddAsync(new PreviousPDF() { SubjectVisitId = subjectVisitId, Path = relativePath, FileName = fileRealName });
|
||||
|
||||
await _repository.AddAsync(new PreviousPDF() { ClinicalDataId= clinical.Id, SubjectVisitId = subjectVisitId, Path = relativePath, FileName = fileRealName });
|
||||
return serverFilePath;
|
||||
});
|
||||
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上传临床数据
|
||||
/// </summary>
|
||||
/// <param name="clinicalDataId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("ClinicalData/UploadClinicalData/{trialId:guid}/{clinicalDataId:guid}")]
|
||||
[HttpPost("ClinicalData/UploadClinicalData/{clinicalDataId:guid}")]
|
||||
[DisableRequestSizeLimit]
|
||||
public async Task<IResponseOutput> UploadClinicalData(Guid clinicalDataId)
|
||||
{
|
||||
|
||||
var sv = _repository.Where<ClinicalData>(t => t.Id == clinicalDataId).Select(t => new { t.TrialId, t.SubjectId }).FirstOrDefault().IfNullThrowException();
|
||||
var sv = _repository.Where<ClinicalData>(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 });
|
||||
await _repository.AddAsync(new PreviousPDF() { SubjectVisitId = clinicalDataId, ClinicalDataId= clinicalDataId, Path = relativePath, FileName = fileRealName });
|
||||
|
||||
return serverFilePath;
|
||||
});
|
||||
@@ -421,9 +437,6 @@ namespace IRaCIS.Core.API.Controllers
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上传非Dicom 文件 支持压缩包 多文件上传
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user