diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index edea38c2a..2d859246e 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -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 _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 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 UploadVisitClinicalData(Guid subjectVisitId) { await QCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId); - var sv = _repository.Where(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(); } - /// /// 上传临床数据 /// /// /// - [HttpPost("ClinicalData/UploadClinicalData/{trialId:guid}/{clinicalDataId:guid}")] + [HttpPost("ClinicalData/UploadClinicalData/{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(); + 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 }); + 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(); } - - - /// /// 上传非Dicom 文件 支持压缩包 多文件上传 /// diff --git a/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs index bb909cccd..4a16162e7 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs @@ -37,6 +37,7 @@ namespace IRaCIS.Core.API options.SwaggerDoc("Management", new OpenApiInfo { Title = "管理模块", Version = "Management" }); options.SwaggerDoc("Image", new OpenApiInfo { Title = "影像模块", Version = "Image" }); options.SwaggerDoc("Reading", new OpenApiInfo { Title = "读片模块", Version = "Reading" }); + // 接口排序 options.OrderActionsBy(o => o.GroupName); @@ -107,6 +108,7 @@ namespace IRaCIS.Core.API options.SwaggerEndpoint($"swagger/Management/swagger.json", "管理模块"); options.SwaggerEndpoint($"swagger/Image/swagger.json", "影像模块"); options.SwaggerEndpoint($"swagger/Reading/swagger.json", "读片模块"); + //路径配置,设置为空,表示直接在根域名(localhost:8001)访问该文件, //注意localhost:8001/swagger是访问不到的,去launchSettings.json把launchUrl去掉,如果你想换一个路径,直接写名字即可,比如直接写c.Route = "doc"; diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index de915ef90..327cfeb50 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -427,6 +427,21 @@ + + + 项目Id + + + + + 受试者ID + + + + + 访视或者阅片ID + + 项目ID @@ -497,6 +512,16 @@ 数据 + + + 项目ID + + + + + 设置阅片是否生效 + + 截止访视 @@ -2571,13 +2596,25 @@ + + + 获取 + + + + 删除 - + + + + 阅片期配置 + + 新增或者修改 @@ -2592,6 +2629,13 @@ + + + 设置阅片期配置是否生效 + + + + 删除 @@ -2599,6 +2643,11 @@ + + + 生成的阅片模块(在大列表上展示的) + + 获取读片模块 diff --git a/IRaCIS.Core.Application/Service/Reading/ClinicalDataService.cs b/IRaCIS.Core.Application/Service/Reading/ClinicalDataService.cs index 877182e0e..fc2d529e8 100644 --- a/IRaCIS.Core.Application/Service/Reading/ClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ClinicalDataService.cs @@ -60,14 +60,31 @@ namespace IRaCIS.Application.Services return pageList; } + /// + /// 获取 + /// + /// + /// + [HttpPost] + public async Task> ClinicalDataView(ClinicalDataInDto inDto) + { + var list= await _clinicalDataRepository.AsQueryable().Where(x => x.TrialId == inDto.TrialId) + .Where(x => (x.ClinicalLevel == ClinicalLevel.Subject && x.SubjectId == inDto.SubjectId) || x.VisitOrReadId == inDto.VisitOrReadId) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(); + return list; + } - /// - /// 删除 - /// - /// - /// - [HttpDelete("{ClinicalDataId:guid}")] + + + + /// + /// 删除 + /// + /// + /// + [HttpDelete("{ClinicalDataId:guid}")] public async Task DeleteClinicalData(Guid clinicalDataId) { var success = await _repository.BatchDeleteAsync(t => t.Id == clinicalDataId); diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalDataServiceViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalDataServiceViewModel.cs index bb483d68e..2e597b94f 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalDataServiceViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalDataServiceViewModel.cs @@ -18,6 +18,23 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto } + public class ClinicalDataInDto + { + /// + /// 项目Id + /// + public Guid TrialId { get; set; } + + /// + /// 受试者ID + /// + public Guid SubjectId { get; set; } + + /// + /// 访视或者阅片ID + /// + public Guid VisitOrReadId { get; set; } + } public class ClinicalDataQuery { /// diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs index 1cb904a9b..acc47a514 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs @@ -18,6 +18,19 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto } + public class SetReadingPeriodSetEffect + { + /// + /// 项目ID + /// + public Guid Id { get; set; } + + /// + /// 设置阅片是否生效 + /// + public bool IsTakeEffect { get; set; } + } + public class ReadingPeriodSetQuery { diff --git a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs index f1f6a9c43..04b179c56 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs @@ -11,6 +11,9 @@ using IRaCIS.Core.Domain.Share.Reading; namespace IRaCIS.Application.Services { + /// + /// 生成的阅片模块(在大列表上展示的) + /// [ApiExplorerSettings(GroupName = "Reading")] public class ReadModuleService : BaseService { @@ -31,9 +34,8 @@ namespace IRaCIS.Application.Services /// 获取读片模块 /// [HttpPost] - public async Task GetReadModule(GetReadModuleDto dto) + public async Task<(PageOutput,int)> GetReadModule(GetReadModuleDto dto) { - var subjectquery = _subjectRepository.WhereIf(dto.TrialId!=null, x => x.TrialId == dto.TrialId).Include(x => x.SubjectVisitList).Include(x=>x.Site) .Select(x => new GetReadModuleDtoOut { @@ -56,27 +58,10 @@ namespace IRaCIS.Application.Services VisitName = y.VisitName, }).ToList() - }); - - var pageList = await subjectquery.ToPagedListAsync(dto.PageIndex, dto.PageSize, dto.SortField == null ? "SiteCode" : dto.SortField, dto.SortAsc); - - - GetReadModuleResultDto resultDto = new GetReadModuleResultDto() - { - CurrentPageData = pageList.CurrentPageData.ToList(), - PageSize = pageList.PageSize, - MaxLength = pageList.CurrentPageData.ToList().Max(x => x.Data.Count), - PageIndex = pageList.PageIndex, - TotalCount = pageList.TotalCount, - - }; - - - - return resultDto; + return (pageList, pageList.CurrentPageData.ToList().Max(x => x.Data.Count)); } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs index 0b221da7e..32eb50839 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs @@ -11,6 +11,9 @@ using IRaCIS.Core.Domain.Share.Reading; namespace IRaCIS.Application.Services { + /// + /// 阅片期配置 + /// [ApiExplorerSettings(GroupName = "Reading")] public class ReadingPeriodSetService : BaseService { @@ -59,13 +62,31 @@ namespace IRaCIS.Application.Services } + /// + /// 设置阅片期配置是否生效 + /// + /// + /// + [HttpPut] + public async Task SetReadingPeriodSetEffect(SetReadingPeriodSetEffect indto) + { - /// - /// 删除 - /// - /// - /// - [HttpDelete("{readingPeriodSetId:guid}")] + var readquery =await _readingPeriodSetRepository.UpdatePartialNowNoQueryAsync(indto.Id, x => new ReadingPeriodSet() { + IsTakeEffect = indto.IsTakeEffect + }); + + + await _readingPeriodSetRepository.SaveChangesAsync(); + } + + + + /// + /// 删除 + /// + /// + /// + [HttpDelete("{readingPeriodSetId:guid}")] public async Task DeleteReadingPeriodSet(Guid readingPeriodSetId) { var success = await _repository.BatchDeleteAsync(t => t.Id == readingPeriodSetId); diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index e74ca96d3..facea7ae3 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -39,9 +39,9 @@ namespace IRaCIS.Core.Domain.Share.Reading /// - /// 受试者范围 + /// 阅片期范围 /// - public enum SubjectScopeEnum + public enum ReadingScopeEnum { /// /// 全部 @@ -148,9 +148,9 @@ namespace IRaCIS.Core.Domain.Share.Reading } /// - /// 临床分组类型 + /// 临床分组级别 /// - public enum ClinicalScopeType + public enum ClinicalLevel { /// /// 受试者 @@ -160,7 +160,7 @@ namespace IRaCIS.Core.Domain.Share.Reading /// /// 访视 /// - Visit = 1, + SubjectVisit = 1, /// /// 阅片 diff --git a/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs b/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs index cf3a175f6..8ae223d9d 100644 --- a/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs +++ b/IRaCIS.Core.Domain/QC/ClinicalData/PreviousPDF.cs @@ -51,8 +51,10 @@ namespace IRaCIS.Core.Domain.Models /// 临床数据ID /// public Guid? ClinicalDataId { get; set; } - + } + + } diff --git a/IRaCIS.Core.Domain/Reading/ClinicalData.cs b/IRaCIS.Core.Domain/Reading/ClinicalData.cs index 93003d8ed..019efb8ef 100644 --- a/IRaCIS.Core.Domain/Reading/ClinicalData.cs +++ b/IRaCIS.Core.Domain/Reading/ClinicalData.cs @@ -31,9 +31,9 @@ namespace IRaCIS.Core.Domain.Models public Guid? VisitOrReadId { get; set; } /// - /// 分组类型(受试者) + /// 临床级别 /// - public ClinicalScopeType? ScopeType { get; set; } + public ClinicalLevel? ClinicalLevel { get; set; } /// /// 数据类型 @@ -41,7 +41,7 @@ namespace IRaCIS.Core.Domain.Models public ClinicalDataType? DataType { get; set; } /// - /// 上传方式() + /// 上传方式 /// public ClinicalUploadType? UploadType { get; set; } diff --git a/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs b/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs index 9a67725c7..617db7e4d 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs @@ -26,14 +26,14 @@ namespace IRaCIS.Core.Domain.Models public string ReadingPeriodName { get; set; } /// - /// 受试者范围 + /// 阅片范围 /// - public SubjectScopeEnum? SubjectScope { get; set; } + public ReadingScopeEnum? ReadingScope { get; set; } /// - /// 范围ID + /// 中心ID /// - public Guid? ScopeId { get; set; } + public Guid? SiteId { get; set; } /// /// 截止日期 @@ -46,9 +46,14 @@ namespace IRaCIS.Core.Domain.Models public decimal? ExpirationVisit { get; set; } /// - /// 状态 + /// 访视计划ID /// - public ReadingPeriodStatus? Status { get; set; } + public Guid? VisitStageId { get; set; } + + /// + /// 是否生效 + /// + public bool? IsTakeEffect { get; set; } /// /// 创建时间 @@ -60,6 +65,7 @@ namespace IRaCIS.Core.Domain.Models /// public Guid CreateUserId { get; set; } + } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 6e31f1de9..00b7f666c 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -177,6 +177,10 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet ReadingPeriodSet { get; set; } public virtual DbSet ReadModule { get; set; } + + public virtual DbSet ClinicalData { get; set; } + + #endregion #region Subject and Visit and study