增加拉取查询
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2025-03-20 15:04:45 +08:00
parent e06b47c8b3
commit 5a99f476f9
2 changed files with 104 additions and 37 deletions

View File

@ -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<TrialPatientDTO> 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 public class NewTrialView : PatientJoinTrialInitView
{ {
@ -139,7 +165,7 @@ namespace IRaCIS.Application.Contracts
} }
public class PatientJoinedTrialQuery:PageInput public class PatientJoinedTrialQuery : PageInput
{ {
[NotDefault] [NotDefault]
public Guid PatientId { get; set; } public Guid PatientId { get; set; }
@ -978,7 +1004,7 @@ namespace IRaCIS.Application.Contracts
public long FileSize { get; set; } public long FileSize { get; set; }
public int StudyCount { get; set; } public int StudyCount { get; set; }
} }
public class VisitPatientStudyView : PatientStudySelectDto public class VisitPatientStudyView : PatientStudySelectDto
{ {

View File

@ -3067,32 +3067,52 @@ namespace IRaCIS.Application.Services
await client.SendAsync(); 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 else
{ {
//找到该项目下的患者,以及每个患者最新的检查之后的检查 //找到该项目下的患者,以及每个患者最新的检查之后的检查
var list = await _subjectRepository.Where(t => t.TrialId == inQuery.TrialId).SelectMany(t => t.SubjectPatientList).Select(t => new var list = await _subjectRepository.Where(t => t.TrialId == inQuery.TrialId).SelectMany(t => t.SubjectPatientList)
{ .WhereIf(inQuery.PatientID.IsNotNullOrEmpty(), t => t.Patient.PatientIdStr == inQuery.PatientID)
t.Patient.PatientIdStr, .Select(t => new
MaxStudyTime = t.Patient.SCPStudyList.Max(t => t.StudyTime) {
}).ToListAsync(); 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) foreach (var patient in list)
{ {
var cloneInQuery = inQuery.Clone(); var cloneInQuery = inQuery.Clone();
cloneInQuery.PatientID = patient.PatientIdStr; 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); var request = CreateStudyRequest(cloneInQuery, modality);
request.OnResponseReceived += responseDelegate; request.OnResponseReceived += responseDelegate;
@ -3102,25 +3122,18 @@ namespace IRaCIS.Application.Services
} }
await client.SendAsync(); 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<IResponseOutput<List<SCUStudyView>>> GetTrialPatientStudyList(SCUQuery inQuery, public async Task<List<NewTrialSelectDTO>> GetUserJoinedTrialPatientList()
// [FromServices] IRepository<DicomAE> _dicomAEReposiotry, {
// [FromServices] ILogger<PatientService> _logger) 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
//}
/// <summary> /// <summary>
/// 批量验证Cmove 检查在系统存在与否 /// 批量验证Cmove 检查在系统存在与否