/// <summary> /// Queries local datastore for studies based on specified search function. /// </summary> private void QueryStudies(string query, Converter <string, KeyValuePair <string, double>[]> searchFunc) { // if there is a previous task that may still be running, disconnect it so we effectively abandon it if (_queryStudiesTask != null) { _queryStudiesTask.ProgressUpdated -= OnQueryStudiesProgressUpdate; } // clear existing items _searchResults.Items.Clear(); // create new task to query similar studies asynchronously so as not to block UI _queryStudiesTask = new BackgroundTask( delegate(IBackgroundTaskContext ctx) { KeyValuePair <string, double>[] similarStudyUids = searchFunc(query); foreach (KeyValuePair <string, double> kvp in similarStudyUids) { string studyUid = kvp.Key; double score = kvp.Value; QueryParameters queryParams = new QueryParameters(); queryParams.Add("PatientsName", ""); queryParams.Add("PatientId", ""); queryParams.Add("AccessionNumber", ""); queryParams.Add("StudyDescription", ""); queryParams.Add("ModalitiesInStudy", ""); queryParams.Add("StudyDate", ""); queryParams.Add("StudyInstanceUid", studyUid); // currently only the local dicom store is supported StudyItemList similarStudyItems = ImageViewerComponent.FindStudy(queryParams, null, "DICOM_LOCAL"); // should only ever be one result at most // if zero results, it means the study exists in the tag database but not in the local dicom store StudyItem studyItem = CollectionUtils.FirstElement(similarStudyItems); if (studyItem != null) { StudyTableEntry entry = new StudyTableEntry(studyItem, MakeTagsString(_database.GetTagsForStudy(studyUid)), score); ctx.ReportProgress(new StudyQueryProgress(entry)); } } }, false); _queryStudiesTask.ProgressUpdated += OnQueryStudiesProgressUpdate; _queryStudiesTask.Run(); }
private static StudyItemList Query(QueryParameters queryParams, List <KeyValuePair <string, Exception> > failedServerInfo, List <IServerTreeNode> servers) { StudyItemList aggregateStudyItemList = new StudyItemList(); foreach (IServerTreeNode serverNode in servers) { try { StudyItemList serverStudyItemList; if (serverNode.IsLocalDataStore) { serverStudyItemList = ImageViewerComponent.FindStudy(queryParams, null, "DICOM_LOCAL"); } else if (serverNode.IsServer) { Server server = (Server)serverNode; ApplicationEntity ae = new ApplicationEntity( server.Host, server.AETitle, server.Name, server.Port, server.IsStreaming, server.HeaderServicePort, server.WadoServicePort); serverStudyItemList = ImageViewerComponent.FindStudy(queryParams, ae, "DICOM_REMOTE"); } else { throw new Exception("Server is not queryable"); } aggregateStudyItemList.AddRange(serverStudyItemList); } catch (Exception e) { // keep track of the failed server names and exceptions failedServerInfo.Add(new KeyValuePair <string, Exception>(serverNode.Name, e)); } } return(aggregateStudyItemList); }
public bool Load(string filename) { var extensions = new MediaFileSetReaderExtensionPoint(); MediaFileSet fileSet = null; foreach (IMediaFileSetReader item in extensions.CreateExtensions()) { if (item.TryRead(filename, out fileSet)) { break; } } if (fileSet == null) { return(false); } _dummyStudyTable.Items.AddRange(ImageViewerComponent.FindStudy(new QueryParameters(), fileSet, "MediaFileSet")); return(true); }