/// <summary>
        /// Creates the presentation images for a given key object selection document.
        /// </summary>
        /// <param name="keyObjectDocument">The key object selection document from which presentation images are to be created.</param>
        /// <returns>A list of created presentation images.</returns>
        protected virtual List <IPresentationImage> CreateImages(KeyObjectSelectionDocumentIod keyObjectDocument)
        {
            List <IPresentationImage> images = new List <IPresentationImage>();

            if (_studyTree == null)
            {
                Platform.Log(LogLevel.Warn, "Key object document cannot be used to create images because there is no study tree to build from.");
            }
            else
            {
                IList <IKeyObjectContentItem> content = new KeyImageDeserializer(keyObjectDocument).Deserialize();
                foreach (IKeyObjectContentItem item in content)
                {
                    if (item is KeyImageContentItem)
                    {
                        images.AddRange(CreateImages((KeyImageContentItem)item));
                    }
                    else
                    {
                        Platform.Log(LogLevel.Warn, "Unsupported key object content value type");
                    }
                }
            }

            return(images);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the presentation images for a given key object selection document.
        /// </summary>
        /// <param name="keyObjectDocument">The key object selection document from which presentation images are to be created.</param>
        /// <returns>A list of created presentation images.</returns>
        protected virtual List <IPresentationImage> CreateImages(KeyObjectSelectionDocumentIod keyObjectDocument)
        {
            List <IPresentationImage> images = new List <IPresentationImage>();

            if (_studyTree == null)
            {
                Platform.Log(LogLevel.Warn, "Key object document cannot be used to create images because there is no study tree to build from.");
            }
            else
            {
                IList <IKeyObjectContentItem> content = new KeyImageDeserializer(keyObjectDocument).Deserialize();
                var evidence = new HierarchicalSopInstanceReferenceDictionary(keyObjectDocument.KeyObjectDocument.CurrentRequestedProcedureEvidenceSequence);
                foreach (IKeyObjectContentItem item in content)
                {
                    if (item is KeyImageContentItem)
                    {
                        images.AddRange(CreateImages((KeyImageContentItem)item, evidence));
                    }
                    else
                    {
                        Platform.Log(LogLevel.Warn, "Unsupported key object content value type");
                    }
                }
            }

            return(images);
        }
        /// <summary>
        /// Creates the presentation images for a given key object selection document.
        /// </summary>
        /// <param name="keyObjectDocument">The key object selection document from which presentation images are to be created.</param>
        /// <returns>A list of created presentation images.</returns>
        protected virtual List <IPresentationImage> CreateImages(KeyObjectSelectionDocumentIod keyObjectDocument)
        {
            List <IPresentationImage> images = new List <IPresentationImage>();

            if (_studyTree == null)
            {
                Platform.Log(LogLevel.Warn, "Key object document cannot be used to create images because there is no study tree to build from.");
            }
            else
            {
                try
                {
                    IList <IKeyObjectContentItem> content = new KeyImageDeserializer(keyObjectDocument).Deserialize();
                    var evidence = new HierarchicalSopInstanceReferenceDictionary(keyObjectDocument.KeyObjectDocument.CurrentRequestedProcedureEvidenceSequence);
                    foreach (IKeyObjectContentItem item in content)
                    {
                        try
                        {
                            var contentItem = item as KeyImageContentItem;
                            if (contentItem != null)
                            {
                                images.AddRange(CreateImages(contentItem, evidence));
                            }
                            else
                            {
                                Platform.Log(LogLevel.Warn, "Unsupported key object content value type");
                            }
                        }
                        catch (Exception ex)
                        {
                            // catches KO errors with individual content items, allowing as many items as possible to be created
                            Platform.Log(LogLevel.Warn, ex, SR.MessageKeyObjectDeserializeFailure);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // catches KO errors with the entire document
                    Platform.Log(LogLevel.Warn, ex, SR.MessageKeyObjectDeserializeFailure);
                }
            }

            // return a KO error placeholder, otherwise the sop will be treated later as an unsupported sop class
            if (images.Count == 0 && keyObjectDocument.DataSource is Sop)
            {
                images.Add(PlaceholderDisplaySetFactory.CreatePlaceholderImage((Sop)keyObjectDocument.DataSource, SR.MessageKeyObjectDeserializeFailure));
            }
            return(images);
        }
        public KeyImageInformation(StudyTree studyTree, Sop keyObjectSelectionDocument)
            : base(CreateClipboardItems(studyTree, keyObjectSelectionDocument))
        {
            var koDeserializer = new KeyImageDeserializer(keyObjectSelectionDocument);
            var description    = koDeserializer.DeserializeDescriptions().OfType <KeyObjectDescriptionContentItem>().FirstOrDefault();
            var author         = koDeserializer.DeserializeObserverContexts().OfType <PersonObserverContextContentItem>().FirstOrDefault();

            _parentStudyInstanceUid = keyObjectSelectionDocument.StudyInstanceUid;
            _documentInstanceUid    = keyObjectSelectionDocument.SopInstanceUid;
            _author            = author != null ? author.PersonObserverName : string.Empty;
            _description       = description != null ? description.Description : string.Empty;
            _documentTitle     = koDeserializer.DocumentTitle ?? KeyObjectSelectionDocumentTitleContextGroup.OfInterest;
            _seriesDescription = keyObjectSelectionDocument.SeriesDescription;
            _seriesNumber      = keyObjectSelectionDocument.SeriesNumber;
            _contentDateTime   = DateTimeParser.ParseDateAndTime(null, keyObjectSelectionDocument.ContentDate, keyObjectSelectionDocument.ContentTime);
            _name = string.Format(SR.FormatOriginalKeyImageSelection, keyObjectSelectionDocument.SeriesNumber, keyObjectSelectionDocument.SeriesDescription, Format.DateTime(_contentDateTime));
        }