/// <summary>
        /// Serializes the presentation state of the given images to the current state object.
        /// </summary>
        /// <param name="images">The images whose presentation states are to be serialized.</param>
        /// <exception cref="InvalidOperationException">Thrown if the presentation state has already been serialized to a file.</exception>
        public override void Serialize(IEnumerable <IPresentationImage> images)
        {
            CheckSerialized(false);

            // create UIDs if needed now
            this.PresentationSeriesInstanceUid = CreateUid(this.PresentationSeriesInstanceUid);
            this.PresentationSopInstanceUid    = CreateUid(this.PresentationSopInstanceUid);

            _serialized = true;

            var specificCharacterSet = _specificCharacterSet ?? string.Empty;

            DataSet.SpecificCharacterSet = specificCharacterSet;
            DataSet[DicomTags.SpecificCharacterSet].SetStringValue(specificCharacterSet);

            GeneralEquipmentModuleIod generalEquipmentModule = new GeneralEquipmentModuleIod(this.DataSet);

            generalEquipmentModule.Manufacturer                = this.Manufacturer ?? string.Empty; // this one is type 2 - all other GenEq attributes are type 3
            generalEquipmentModule.ManufacturersModelName      = string.IsNullOrEmpty(this.ManufacturersModelName) ? null : this.ManufacturersModelName;
            generalEquipmentModule.DeviceSerialNumber          = string.IsNullOrEmpty(this.DeviceSerialNumber) ? null : this.DeviceSerialNumber;
            generalEquipmentModule.SoftwareVersions            = string.IsNullOrEmpty(this.SoftwareVersions) ? null : this.SoftwareVersions;
            generalEquipmentModule.InstitutionName             = string.IsNullOrEmpty(this.Institution.Name) ? null : this.Institution.Name;
            generalEquipmentModule.InstitutionAddress          = string.IsNullOrEmpty(this.Institution.Address) ? null : this.Institution.Address;
            generalEquipmentModule.InstitutionalDepartmentName = string.IsNullOrEmpty(this.Institution.DepartmentName) ? null : this.Institution.DepartmentName;
            generalEquipmentModule.StationName = string.IsNullOrEmpty(this.StationName) ? null : this.StationName;

            GeneralSeriesModuleIod generalSeriesModule = new GeneralSeriesModuleIod(this.DataSet);

            generalSeriesModule.InitializeAttributes();
            generalSeriesModule.SeriesDateTime    = this.PresentationSeriesDateTime;
            generalSeriesModule.SeriesDescription = this.PresentationContentLabel;
            generalSeriesModule.SeriesInstanceUid = this.PresentationSeriesInstanceUid;
            generalSeriesModule.SeriesNumber      = this.PresentationSeriesNumber;

            PresentationSeriesModuleIod presentationSeriesModule = new PresentationSeriesModuleIod(this.DataSet);

            presentationSeriesModule.InitializeAttributes();
            presentationSeriesModule.Modality = Modality.PR;

            SopCommonModuleIod sopCommonModule = new SopCommonModuleIod(this.DataSet);

            sopCommonModule.SopInstanceUid = this.PresentationSopInstanceUid;
            sopCommonModule.SopClassUid    = this.PresentationSopClass.Uid;

            PresentationStateIdentificationModuleIod presentationStateIdentificationModule = new PresentationStateIdentificationModuleIod(this.DataSet);

            presentationStateIdentificationModule.InitializeAttributes();
            presentationStateIdentificationModule.ContentLabel   = this.PresentationContentLabel;
            presentationStateIdentificationModule.InstanceNumber = this.PresentationInstanceNumber;
            presentationStateIdentificationModule.PresentationCreationDateTime = Platform.Time;

            PerformSerialization(images);

            _dicomFile.SourceApplicationEntityTitle = this.SourceAETitle;
            _dicomFile.MediaStorageSopClassUid      = this.PresentationSopClassUid;
            _dicomFile.MediaStorageSopInstanceUid   = this.PresentationSopInstanceUid;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Serializes the presentation state of the given images to the current state object.
        /// </summary>
        /// <param name="images">The images whose presentation states are to be serialized.</param>
        /// <exception cref="InvalidOperationException">Thrown if the presentation state has already been serialized to a file.</exception>
        public override void Serialize(IEnumerable <IPresentationImage> images)
        {
            AssertNotSerialized();

            // create UIDs if needed now
            PresentationSeriesInstanceUid = CreateUid(PresentationSeriesInstanceUid);
            PresentationSopInstanceUid    = CreateUid(PresentationSopInstanceUid);

            _serialized = true;

            var imageList          = images.ToList();
            var sopInstanceFactory = new PrototypeSopInstanceFactory {
                Institution = Institution, StationName = StationName, SpecificCharacterSet = SpecificCharacterSet
            };

            sopInstanceFactory.InitializeDataSet(imageList.OfType <IImageSopProvider>().First().ImageSop.DataSource, DataSet);

            GeneralSeriesModuleIod generalSeriesModule = new GeneralSeriesModuleIod(DataSet);

            generalSeriesModule.InitializeAttributes();
            generalSeriesModule.SeriesDateTime    = PresentationSeriesDateTime;
            generalSeriesModule.SeriesDescription = PresentationContentLabel;
            generalSeriesModule.SeriesInstanceUid = PresentationSeriesInstanceUid;
            generalSeriesModule.SeriesNumber      = PresentationSeriesNumber;

            PresentationSeriesModuleIod presentationSeriesModule = new PresentationSeriesModuleIod(DataSet);

            presentationSeriesModule.InitializeAttributes();
            presentationSeriesModule.Modality = Modality.PR;

            SopCommonModuleIod sopCommonModule = new SopCommonModuleIod(DataSet);

            sopCommonModule.SopInstanceUid = PresentationSopInstanceUid;
            sopCommonModule.SopClassUid    = PresentationSopClass.Uid;

            PresentationStateIdentificationModuleIod presentationStateIdentificationModule = new PresentationStateIdentificationModuleIod(DataSet);

            presentationStateIdentificationModule.InitializeAttributes();
            presentationStateIdentificationModule.ContentLabel   = PresentationContentLabel;
            presentationStateIdentificationModule.InstanceNumber = PresentationInstanceNumber;
            presentationStateIdentificationModule.PresentationCreationDateTime = Platform.Time;

            PerformSerialization(imageList);

            _dicomFile.SourceApplicationEntityTitle = SourceAETitle;
            _dicomFile.MediaStorageSopClassUid      = PresentationSopClassUid;
            _dicomFile.MediaStorageSopInstanceUid   = PresentationSopInstanceUid;
        }