Esempio n. 1
0
        private static void AddReferencedSopSequence(ReferencedSopItemCollection storageCommitItems,
			uint tag,
			DvtkData.Dimse.AttributeSet attributeSet,
			InstanceStateEnum newInstanceState)
        {
            ushort group = (ushort)(tag >> 16);
            ushort element = (ushort)(tag & 0x0000FFFF);
            DvtkData.Dimse.Tag tagValue = new DvtkData.Dimse.Tag(group, element);

            DvtkData.Dimse.Attribute referencedSopSequence = attributeSet.GetAttribute(tagValue);
            if (referencedSopSequence != null)
            {
                attributeSet.Remove(referencedSopSequence);
            }

            referencedSopSequence = new DvtkData.Dimse.Attribute(tag, DvtkData.Dimse.VR.SQ);
            SequenceOfItems referencedSopSequenceOfItems = new SequenceOfItems();
            referencedSopSequence.DicomValue = referencedSopSequenceOfItems;

            foreach(ReferencedSopItem  referencedSopItem in storageCommitItems)
            {
                if (((referencedSopItem.InstanceState == InstanceStateEnum.InstanceStored) &&
                    (newInstanceState == InstanceStateEnum.InstanceMppsCompleted)) ||
                    ((referencedSopItem.InstanceState == InstanceStateEnum.InstanceMppsCompleted) &&
                    (newInstanceState == InstanceStateEnum.InstanceStorageCommitRequested)))
                {

                    DvtkData.Dimse.SequenceItem referencedSopSequenceItem = new DvtkData.Dimse.SequenceItem();
                    referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber,
                        DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber,
                        DvtkData.Dimse.VR.UI, referencedSopItem.SopClassUid);
                    referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber,
                        DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber,
                        DvtkData.Dimse.VR.UI, referencedSopItem.SopInstanceUid);
                    referencedSopItem.InstanceState = newInstanceState;
                    referencedSopSequenceOfItems.Sequence.Add(referencedSopSequenceItem);
                }
            }
            attributeSet.Add(referencedSopSequence);
        }