internal void RefreshInternal() { _seriesTable.Items.Clear(); try { var storeQuery = _studyItem.Server.IsSupported <IStudyStoreQuery>() ? _studyItem.Server.GetService <IStudyStoreQuery>() : new StudyRootQueryStoreAdapter(_studyItem.Server.GetService <IStudyRootQuery>()); using (var bridge = new StudyStoreBridge(storeQuery)) { var entries = bridge.GetSeriesEntries(_studyItem.StudyInstanceUid); _seriesTable.Items.AddRange(entries.Select(e => new SeriesTableItem(e))); } } catch (Exception e) { ExceptionHandler.Report(e, Host.DesktopWindow); } }
private static List <StudyEntry> GetStudyEntries(IDicomServiceNode server, StudyRootStudyIdentifier criteria) { // N.B.: we have to handle multiple modalities in the search criteria this way because DICOM does not allow multi-valued search on modality (if you think it does, re-read the standard carefully!) // normalize the list of modalities (no duplicates, and empty string only if no other modalities) var modalities = (criteria.ModalitiesInStudy ?? new string[0]).Except(new[] { string.Empty }).Distinct().ToList(); if (modalities.Count == 0) { modalities.Add(string.Empty); } var storeQuery = server.IsSupported <IStudyStoreQuery>() ? server.GetService <IStudyStoreQuery>() : new StudyRootQueryStoreAdapter(server.GetService <IStudyRootQuery>()); using (var bridge = new StudyStoreBridge(storeQuery)) { IEnumerable <StudyEntry> results = new StudyEntry[0]; foreach (var modality in modalities) { var modalityCriteria = new StudyRootStudyIdentifier(criteria) { ModalitiesInStudy = new[] { modality } }; var modalityResults = bridge.GetStudyEntries(modalityCriteria).ToList(); // 'ToList' to execute query here and now if ((modality == string.Empty) || (modalityResults.Any() && modalityResults.All(s => s.Study.ModalitiesInStudy.All(string.IsNullOrEmpty))) || // 'All' returns true if sequence is empty, so make sure it's not empty! (modalityResults.Any(s => !s.Study.ModalitiesInStudy.Any(m => modality.Equals(m, StringComparison.InvariantCultureIgnoreCase))))) { // if modality was not filtered in the query // or if all results (non-empty) do not return modality (i.e. the server does not support querying or returning this optional tag) // or if any result does not match the queried modality (i.e. the server does not support querying on this optional tag) // then these are all the unique results we'll ever get, and we can skip the other modalities return(modalityResults); } results = results.Union(modalityResults, s => s.Study.StudyInstanceUid); } return(results.ToList()); } }
private static bool StudyExistsOnLocal(string studyInstanceUid) { using (var bridge = new StudyStoreBridge()) return(bridge.QueryByStudyInstanceUid(studyInstanceUid).Count > 0); }