diff --git a/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs b/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs index bb57325dd..fae48a924 100644 --- a/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs +++ b/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs @@ -27,6 +27,32 @@ namespace IRaCIS.Application.Contracts } + public class NewTrialSelectDTO + { + public Guid TrialId { get; set; } + + public string TrialCode { get; set; } + public string ExperimentName { get; set; } + public string ResearchProgramNo { get; set; } + + public string TrialStatusStr { get; set; } + + public DateTime CreateTime { get; set; } + + + + public List PatientList { get; set; } + + } + + public class TrialPatientDTO + { + public string PatientIdStr { get; set; } + public string PatientName { get; set; } + public string PatientAge { get; set; } + public string PatientSex { get; set; } + } + public class NewTrialView : PatientJoinTrialInitView { @@ -139,7 +165,7 @@ namespace IRaCIS.Application.Contracts } - public class PatientJoinedTrialQuery:PageInput + public class PatientJoinedTrialQuery : PageInput { [NotDefault] public Guid PatientId { get; set; } @@ -978,7 +1004,7 @@ namespace IRaCIS.Application.Contracts public long FileSize { get; set; } public int StudyCount { get; set; } - + } public class VisitPatientStudyView : PatientStudySelectDto { diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index 0c35399b4..2edf49b06 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -3067,32 +3067,52 @@ namespace IRaCIS.Application.Services await client.SendAsync(); - 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); - } } else { //找到该项目下的患者,以及每个患者最新的检查之后的检查 - var list = await _subjectRepository.Where(t => t.TrialId == inQuery.TrialId).SelectMany(t => t.SubjectPatientList).Select(t => new - { - t.Patient.PatientIdStr, - MaxStudyTime = t.Patient.SCPStudyList.Max(t => t.StudyTime) - }).ToListAsync(); + var list = await _subjectRepository.Where(t => t.TrialId == inQuery.TrialId).SelectMany(t => t.SubjectPatientList) + .WhereIf(inQuery.PatientID.IsNotNullOrEmpty(), t => t.Patient.PatientIdStr == inQuery.PatientID) + .Select(t => new + { + t.Patient.PatientIdStr, + MaxStudyTime = t.Patient.SCPStudyList.Max(t => t.StudyTime), + VisitMaxSubmitTime=t.Subject.SubjectVisitList.Max(t=>t.SubmitTime) + }).ToListAsync(); foreach (var patient in list) { var cloneInQuery = inQuery.Clone(); + cloneInQuery.PatientID = patient.PatientIdStr; - cloneInQuery.StudyDate = patient.MaxStudyTime?.ToString("yyyyMMdd") + "-"; - cloneInQuery.StudyTime = patient.MaxStudyTime?.ToString("HHmmss") + "-"; + + + //选择了患者,那么不按照患者最新检查时间之后查询(因为可能存在,先拉去了后面的检查,导致前面的检查查询不到) + if (inQuery.PatientID.IsNotNullOrEmpty()) + { + // pacs 支持的时间 + // 访视提交的时间 + + if (patient.VisitMaxSubmitTime != null) + { + cloneInQuery.StudyDate = patient.VisitMaxSubmitTime?.ToString("yyyyMMdd") + "-"; + cloneInQuery.StudyTime = patient.VisitMaxSubmitTime?.ToString("HHmmss") + "-"; + } + } + else + { + //没有选择患者,那么按照每个患者的最大检查时间之后的查询 + + if (patient.MaxStudyTime != null) + { + cloneInQuery.StudyDate = patient.MaxStudyTime?.ToString("yyyyMMdd") + "-"; + cloneInQuery.StudyTime = patient.MaxStudyTime?.ToString("HHmmss") + "-"; + } + + } + var request = CreateStudyRequest(cloneInQuery, modality); request.OnResponseReceived += responseDelegate; @@ -3102,25 +3122,18 @@ namespace IRaCIS.Application.Services } await client.SendAsync(); - - #region 测试查询出来的数据是否有问题 测试ok后可以删除 - - 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); - } - #endregion - - } + 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); + } @@ -3133,13 +3146,41 @@ namespace IRaCIS.Application.Services } + #region 获取项目维度拉取影像数据下拉框 - //public async Task>> GetTrialPatientStudyList(SCUQuery inQuery, - // [FromServices] IRepository _dicomAEReposiotry, - // [FromServices] ILogger _logger) - //{ + public async Task> GetUserJoinedTrialPatientList() + { + var trialQuery = _trialRepository + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OA + , t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id && t.IsDeleted == false) && t.IsDeleted == false) + .Select(t => new NewTrialSelectDTO() + { + TrialId = t.Id, + TrialCode = t.TrialCode, + ResearchProgramNo = t.ResearchProgramNo, + ExperimentName = t.ExperimentName, + CreateTime = t.CreateTime, + TrialStatusStr = t.TrialStatusStr, + PatientList = t.SubjectList.Where(t => t.Status == SubjectStatus.OnVisit).SelectMany(t => t.SubjectPatientList).Select(u => new TrialPatientDTO() + { + PatientAge = u.Patient.PatientAge, + PatientIdStr = u.Patient.PatientIdStr, + PatientName = u.Patient.PatientName, + PatientSex = u.Patient.PatientSex + }).ToList() + + }); + + + var list = await trialQuery.OrderBy(t => t.CreateTime).ToListAsync(); + + return list; + } + + + + #endregion - //} /// /// 批量验证Cmove 检查在系统存在与否