/// <summary>
        /// Copy from the given source Dataset into the local Dataset as defined by the
        /// default Tag Type list. In addition to the base copy we need to copy attributes from the
        /// Request Attributes Sequence (if present) and the Scheduled Procedure Step (if present).
        /// </summary>
        /// <param name="sourceDataset">Source Dataset used to populate the local Dataset.</param>
        public override void CopyFrom(AttributeSet sourceDataset)
        {
            // perform base copy
            base.CopyFrom(sourceDataset);

            // check if the Request Attributes Sequence is available in the source dataset
            DvtkData.Dimse.Attribute requestAttributesSequence = sourceDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE);
            if (requestAttributesSequence != null)
            {
                SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                    // copy item attributes too
                    base.CopyFrom(item);
                }
            }

            // check if the Scheduled Procedure Step Sequence is available in the source dataset
            DvtkData.Dimse.Attribute scheduledProcedureStepSequence = sourceDataset.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE);
            if (scheduledProcedureStepSequence != null)
            {
                SequenceOfItems sequenceOfItems = (SequenceOfItems)scheduledProcedureStepSequence.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                    // copy item attributes too
                    base.CopyFrom(item);
                }
            }
        }
        /// <summary>
        /// Check if the given match dataset is found in the local dataset using the default Tag Type list.
        /// A check is made to see if all the attributes in the given match dataset are present in the local
        /// dataset. In addition to the base match we need to try to match attributes from the
        /// Request Attributes Sequence (if present).
        /// </summary>
        /// <param name="matchDataset">Match dataset to check.</param>
        /// <returns>Boolean indicating if the match attributes are present in the local dataset.</returns>
        public override bool IsFoundIn(AttributeSet matchDataset)
        {
            bool isFoundIn = base.IsFoundIn(matchDataset);

            if (isFoundIn == false)
            {
                // check if the Request Attributes Sequence is available in the match dataset
                DvtkData.Dimse.Attribute requestAttributesSequence = matchDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE);
                if (requestAttributesSequence != null)
                {
                    SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue;
                    if (sequenceOfItems.Sequence.Count == 1)
                    {
                        // set up a temporary tag list to check the relevant tags in the Request Attributes Sequence
                        TagTypeList itemTagTypeList = new TagTypeList();
                        itemTagTypeList.Add(new TagType(Tag.REQUESTED_PROCEDURE_ID, TagTypeEnum.TagOptional));

                        DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                        // check if found in item
                        isFoundIn = base.IsFoundIn(itemTagTypeList, item);
                    }
                }
            }

            return(isFoundIn);
        }
예제 #3
0
 public static void AppendAttributeValues(this Import.ImportEntity importEntity, AttributeSet attributeSet, Dictionary<string, object> values, string valuesLanguage, bool valuesReadOnly, bool resolveHyperlink)
 {
     foreach (var value in values)
     {
         // Handle special attributes (for example of the system)
         if (value.Key == "IsPublished")
         {
             importEntity.IsPublished = value.Value is bool ? (bool)value.Value : true;
             continue;
         }
         // Handle content-type attributes
         var attribute = attributeSet.GetAttribute(value.Key);
         if (attribute == null)
         {
             throw new ArgumentException("Attribute '" + value.Key + "' does not exist.");
         }
         importEntity.AppendAttributeValue(value.Key, value.Value.ToString(), attribute.Type, valuesLanguage, valuesReadOnly, resolveHyperlink);
     }
 }