修改查询
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2024-12-17 13:40:00 +08:00
parent d0a3ce9a09
commit 1c4d513f5b
9 changed files with 18748 additions and 26 deletions

View File

@ -48,7 +48,7 @@ namespace IRaCIS.Core.Application.ViewModel
public string CalledAE { get; set; } public string CalledAE { get; set; }
public string IP { get; set; } public string IP { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string Modality { get; set; } = string.Empty; public List<string> ModalityList { get; set; }
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public PacsType PacsTypeEnum { get; set; } public PacsType PacsTypeEnum { get; set; }

View File

@ -139,7 +139,7 @@ namespace IRaCIS.Application.Contracts
} }
public class PatientJoinedTrialQuery public class PatientJoinedTrialQuery:PageInput
{ {
[NotDefault] [NotDefault]
public Guid PatientId { get; set; } public Guid PatientId { get; set; }

View File

@ -51,6 +51,6 @@ namespace IRaCIS.Application.Contracts
public class SCUStudyView : SCUBasicInfo public class SCUStudyView : SCUBasicInfo
{ {
public bool IsStudyExist { get; set; }
} }
} }

View File

@ -33,7 +33,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.PacsTypeEnum != null, t => t.PacsTypeEnum == inQuery.PacsTypeEnum) .WhereIf(inQuery.PacsTypeEnum != null, t => t.PacsTypeEnum == inQuery.PacsTypeEnum)
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.CalledAE), t => t.CalledAE.Contains(inQuery.CalledAE)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.CalledAE), t => t.CalledAE.Contains(inQuery.CalledAE))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Description), t => t.Description.Contains(inQuery.Description)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Description), t => t.Description.Contains(inQuery.Description))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Modality), t => t.Modality.Contains(inQuery.Modality)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Modality), t => t.ModalityList.Contains(inQuery.Modality))
.ProjectTo<DicomAEView>(_mapper.ConfigurationProvider); .ProjectTo<DicomAEView>(_mapper.ConfigurationProvider);

View File

@ -22,7 +22,6 @@ using Subject = IRaCIS.Core.Domain.Models.Subject;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
using Medallion.Threading; using Medallion.Threading;
using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure;
using Pipelines.Sockets.Unofficial.Arenas;
using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Contracts;
using MailKit.Search; using MailKit.Search;
using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Office2010.Excel;
@ -48,6 +47,7 @@ using Microsoft.Extensions.Logging;
using DocumentFormat.OpenXml.Wordprocessing; using DocumentFormat.OpenXml.Wordprocessing;
using System; using System;
using Amazon.Runtime.Internal.Transform; using Amazon.Runtime.Internal.Transform;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace IRaCIS.Application.Services namespace IRaCIS.Application.Services
{ {
@ -651,7 +651,7 @@ namespace IRaCIS.Application.Services
/// <param name="inQuery"></param> /// <param name="inQuery"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<IResponseOutput<List<PatientJoinedTrialView>>> GetPatientJoinedTrialList(PatientJoinedTrialQuery inQuery) public async Task<IResponseOutput<PageOutput<PatientJoinedTrialView>>> GetPatientJoinedTrialList(PatientJoinedTrialQuery inQuery)
{ {
var isAdminOrOA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin; var isAdminOrOA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin;
@ -659,7 +659,7 @@ namespace IRaCIS.Application.Services
.Where(t => isAdminOrOA ? true : t.Subject.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) .Where(t => isAdminOrOA ? true : t.Subject.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
.ProjectTo<PatientJoinedTrialView>(_mapper.ConfigurationProvider); .ProjectTo<PatientJoinedTrialView>(_mapper.ConfigurationProvider);
var pageList = await trialQuery.ToListAsync(); var pageList = await trialQuery.ToPagedListAsync(inQuery);
return ResponseOutput.Ok(pageList); return ResponseOutput.Ok(pageList);
} }
@ -671,7 +671,7 @@ namespace IRaCIS.Application.Services
/// <param name="inQuery"></param> /// <param name="inQuery"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<List<PatientStudySimpleView>> GetPatientStudyList(PatientStudyInfoQuery inQuery) public async Task<PageOutput<PatientStudySimpleView>> GetPatientStudyList(PatientStudyInfoQuery inQuery)
{ {
var query = from scpStudy in _studyRepository.Where(t => t.PatientId == inQuery.PatientId) var query = from scpStudy in _studyRepository.Where(t => t.PatientId == inQuery.PatientId)
.WhereIf(inQuery.EarliestStudyTime != null, t => t.StudyTime >= inQuery.EarliestStudyTime) .WhereIf(inQuery.EarliestStudyTime != null, t => t.StudyTime >= inQuery.EarliestStudyTime)
@ -690,13 +690,9 @@ namespace IRaCIS.Application.Services
StudyTime = scpStudy.StudyTime, StudyTime = scpStudy.StudyTime,
}; };
var pageList = await query.ToPagedListAsync(inQuery, nameof(PatientStudySimpleView.StudyTime));
var sortField = string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(PatientStudySimpleView.StudyTime) : inQuery.SortField; return pageList;
var orderQuery = inQuery.Asc ? query.OrderBy(sortField) : query.OrderBy(sortField + " desc");
var list = await orderQuery.ToListAsync();
return list;
} }
@ -2917,7 +2913,7 @@ namespace IRaCIS.Application.Services
/// <param name="_logger"></param> /// <param name="_logger"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<List<SCUStudyView>> GetCFindStudyList(SCUQuery inQuery, public async Task<IResponseOutput<List<SCUStudyView>>> GetCFindStudyList(SCUQuery inQuery,
[FromServices] IRepository<DicomAE> _dicomAEReposiotry, [FromServices] IRepository<DicomAE> _dicomAEReposiotry,
[FromServices] ILogger<PatientService> _logger) [FromServices] ILogger<PatientService> _logger)
{ {
@ -2948,16 +2944,21 @@ namespace IRaCIS.Application.Services
DateOnly datePart = DateOnly.FromDateTime(studyTime); DateOnly datePart = DateOnly.FromDateTime(studyTime);
TimeOnly timePart = TimeOnly.FromDateTime(studyTime); TimeOnly timePart = TimeOnly.FromDateTime(studyTime);
DateTime birthDate = DateTime.ParseExact(response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientBirthDate, ""), "yyyyMMdd", null);
// 格式化为你需要的日期格式例如yyyy-MM-dd
string formattedBirthDate = birthDate.ToString("yyyy-MM-dd");
result.Add(new SCUStudyView() result.Add(new SCUStudyView()
{ {
PatientID = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientID, ""), PatientID = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientID, ""),
PatientName = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientName, ""), PatientName = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientName, ""),
PatientSex = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientSex, ""), PatientSex = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientSex, ""),
PatientBirthDate = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientBirthDate, ""), PatientBirthDate = formattedBirthDate,
StudyID = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.StudyID, ""), StudyID = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.StudyID, ""),
AccessionNumber = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.AccessionNumber, ""), AccessionNumber = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.AccessionNumber, ""),
ModalitiesInStudy = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.ModalitiesInStudy, ""), ModalitiesInStudy = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.ModalitiesInStudy, ""),
StudyDate = datePart.ToString(), StudyDate = datePart.ToString("yyyy-MM-dd"),
StudyTime = timePart.ToString("HH:mm:ss"), StudyTime = timePart.ToString("HH:mm:ss"),
BodyPartExamined = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.BodyPartExamined, ""), BodyPartExamined = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.BodyPartExamined, ""),
StudyDescription = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.StudyDescription, ""), StudyDescription = response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.StudyDescription, ""),
@ -2970,7 +2971,18 @@ namespace IRaCIS.Application.Services
await client.SendAsync(); await client.SendAsync();
} }
return result; var resultInstanceUidList = result.Select(t => t.StudyInstanceUID).ToList();
var existStudyIdList = _studyRepository.Where(t => resultInstanceUidList.Contains(t.StudyInstanceUid))
.Select(t => t.StudyInstanceUid).ToList();
foreach (var item in result)
{
item.IsStudyExist = existStudyIdList.Any(t => t == item.StudyInstanceUID);
}
return ResponseOutput.Ok(result, find);
} }
@ -2979,14 +2991,15 @@ namespace IRaCIS.Application.Services
/// </summary> /// </summary>
/// <param name="inCommand"></param> /// <param name="inCommand"></param>
/// <returns></returns> /// <returns></returns>
public async Task<Dictionary<string, bool>> CMoveVerify(SCUCmoveCommand inCommand) public async Task<Dictionary<string, object>> CMoveVerify(SCUCmoveCommand inCommand)
{ {
var existStudyIdList = _studyRepository.Where(t => inCommand.StudyInstanceUIDList.Contains(t.StudyInstanceUid)).Select(t => t.StudyInstanceUid).ToList(); var existStudyIdList = _studyRepository.Where(t => inCommand.StudyInstanceUIDList.Contains(t.StudyInstanceUid))
.Select(t => new { t.StudyInstanceUid, t.StudyId, PatientId = t.PatientIdStr, t.AccessionNumber }).ToList();
var dic = new Dictionary<string, bool>(); var dic = new Dictionary<string, object>();
foreach (var item in inCommand.StudyInstanceUIDList) foreach (var item in inCommand.StudyInstanceUIDList)
{ {
dic.Add(item, existStudyIdList.Any(t => t == item)); dic.Add(item, existStudyIdList.Any(t => t.StudyInstanceUid == item) ? item : string.Empty);
} }
return dic; return dic;

View File

@ -25,7 +25,7 @@ namespace IRaCIS.Core.Domain.Models
public int Port { get; set; } public int Port { get; set; }
public string Modality { get; set; } public List<string> ModalityList { get; set; }
public string Description { get; set; } public string Description { get; set; }
@ -37,6 +37,8 @@ namespace IRaCIS.Core.Domain.Models
public PacsType PacsTypeEnum { get; set; } public PacsType PacsTypeEnum { get; set; }
public int PacsSearchMaxDays { get; set; }
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IRaCIS.Core.Infra.EFCore.Migrations
{
/// <inheritdoc />
public partial class PACSModify : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Modality",
table: "DicomAE");
migrationBuilder.AddColumn<string>(
name: "ModalityList",
table: "DicomAE",
type: "nvarchar(max)",
nullable: false,
defaultValue: "[]");
migrationBuilder.AddColumn<int>(
name: "PacsSearchMaxDays",
table: "DicomAE",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ModalityList",
table: "DicomAE");
migrationBuilder.DropColumn(
name: "PacsSearchMaxDays",
table: "DicomAE");
migrationBuilder.AddColumn<string>(
name: "Modality",
table: "DicomAE",
type: "nvarchar(400)",
maxLength: 400,
nullable: false,
defaultValue: "");
}
}
}

View File

@ -807,10 +807,12 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
b.Property<DateTime?>("LatestTestTime") b.Property<DateTime?>("LatestTestTime")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Modality") b.Property<string>("ModalityList")
.IsRequired() .IsRequired()
.HasMaxLength(400) .HasColumnType("nvarchar(max)");
.HasColumnType("nvarchar(400)");
b.Property<int>("PacsSearchMaxDays")
.HasColumnType("int");
b.Property<int>("PacsTypeEnum") b.Property<int>("PacsTypeEnum")
.HasColumnType("int"); .HasColumnType("int");