private List <Study> GetStudies(IEnumerable <IImageSet> imageSets, StudyTree studyTree) { List <Study> studies = new List <Study>(); foreach (IImageSet imageSet in imageSets) { studies.Add(studyTree.GetStudy(imageSet.Uid)); } return(studies); }
public Study AddStudy(StudyTree studyTree) { var sops = BuildSops(); foreach (var sop in sops) { studyTree.AddSop(sop); } return(studyTree.GetStudy(sops[0].StudyInstanceUid)); }
private static IDicomServiceNode FindStudySourceServer(StudyTree studyTree, string studyInstanceUid) { try { return(studyTree.GetStudy(studyInstanceUid).Series.SelectMany(s => s.Sops).Select(s => s.DataSource.Server).FirstOrDefault(source => source != null)); } catch (Exception ex) { Platform.Log(LogLevel.Warn, ex, "Failed to identify source server for study {0}", studyInstanceUid); return(null); } }
private T FindSop <T>(string sopInstanceUid, string studyInstanceUid) where T : Sop { if (string.IsNullOrEmpty(sopInstanceUid)) { return(null); } string sameStudyUid = studyInstanceUid; Study sameStudy = _studyTree.GetStudy(sameStudyUid); return(sameStudy != null?sameStudy.Series.Select(series => series.Sops[sopInstanceUid]).OfType <T>().FirstOrDefault() : null); }
//TODO (CR Mar 2010): return Sop and check IsImage. private ImageSop FindReferencedImageSop(string sopInstanceUid, string studyInstanceUid) { if (string.IsNullOrEmpty(sopInstanceUid)) { return(null); } string sameStudyUid = studyInstanceUid; Study sameStudy = _studyTree.GetStudy(sameStudyUid); if (sameStudy != null) { foreach (Series series in sameStudy.Series) { Sop referencedSop = series.Sops[sopInstanceUid]; if (referencedSop != null) { return(referencedSop as ImageSop); } } } return(null); }
public Study AddStudy(StudyTree studyTree) { var sops = BuildSops(); foreach (var sop in sops) studyTree.AddSop(sop); return studyTree.GetStudy(sops[0].StudyInstanceUid); }
public static void Publish(IEnumerable <KeyImageInformation> keyImageInformations, StudyTree studyTree) { var keyImageContexts = keyImageInformations != null?keyImageInformations.ToList() : null; if (keyImageContexts == null || !keyImageContexts.Any()) { return; } if (!AssertIsPublishingServiceAvailable()) { return; } var anyFailed = false; try { var publishers = new Dictionary <string, DicomPublishingHelper>(); var seriesNumberIndex = new Dictionary <string, int>(); var nextSeriesNumberDelegate = new NextSeriesNumberDelegate(studyInstanceUid => { int nextSeriesNumber; if (!seriesNumberIndex.TryGetValue(studyInstanceUid, out nextSeriesNumber)) { var study = studyTree.GetStudy(studyInstanceUid); nextSeriesNumber = study != null ? study.Series.Select(series => series.SeriesNumber).Concat(new[] { 0 }).Max() : 0; } seriesNumberIndex[studyInstanceUid] = ++nextSeriesNumber; return(nextSeriesNumber); }); foreach (var kod in keyImageContexts) { // add each created instance to a publisher by study foreach (var studyInstances in kod.CreateSopInstances(nextSeriesNumberDelegate)) { var publisher = GetValue(publishers, studyInstances.Key.StudyInstanceUid); publisher.OriginServer = studyInstances.Key.OriginServer; publisher.SourceServer = studyInstances.Key.SourceServer; foreach (var f in studyInstances.Value) { publisher.Files.Add(f); } } } // publish all files now foreach (var publisher in publishers.Values) { if (!publisher.Publish()) { anyFailed = true; } } } catch (Exception e) { anyFailed = true; Platform.Log(LogLevel.Error, e, "An unexpected error occurred while trying to publish key images."); } // TODO CR (Sep 12): convert this to a desktop alert if (anyFailed) { // ActiveDesktopWindow may be null when the study is opened from Webstation // By the time viewer closes, there is no browser window to display the error, so log to file only. if (Application.ActiveDesktopWindow == null) { Platform.Log(LogLevel.Error, SR.MessageKeyImagePublishingFailed); } else { Application.ActiveDesktopWindow.ShowMessageBox(SR.MessageKeyImagePublishingFailed, MessageBoxActions.Ok); } } }