//
        // - Methods -
        //
        /// <summary>
        /// Get the next collection of attributes to compare to each other.
        /// If an attribute is not present, a null pointer is returned in the AttributeCollection.
        /// If all attributes have been compared, null is returned.
        /// </summary>
        /// <returns>The attributes to validate.</returns>
        /// 
        private AttributeList DetermineNextAttributes(TagSequence lowestTagSequence)
        {
            AttributeList nextAttributes = new AttributeList();

            nextAttributes.CompareRule = new CompareRule();

            for (int index = 0; index < this.attributeCollections.Count; index++)
            {
                int attributeSetIndex = (int)this.currentAttributeIndices[index];
                AttributeCollectionBase attributeCollectionBase = this.attributeCollections[index];

                if (attributeCollectionBase == null)
                {
                    nextAttributes.Add(null);
                    nextAttributes.CompareRule.Add(null);
                }
                else if (attributeCollectionBase is Hl7AttributeCollection)
                {
                    nextAttributes.Add(null);
                    nextAttributes.CompareRule.Add(null);
                }
                else if (attributeCollectionBase is DicomAttributeCollection)
                {
                    DicomAttributeCollection dicomAttributeCollection = attributeCollectionBase as DicomAttributeCollection;

                    if (attributeSetIndex < dicomAttributeCollection.AttributeSetOnly.Count)
                        // Still unprocessed attributes left in this dataset.
                    {
                        ValidAttribute attributeOnly = dicomAttributeCollection.AttributeSetOnly[attributeSetIndex] as ValidAttribute;

                        if (attributeOnly.TagSequence.LastTag.AsUInt32 == lowestTagSequence.LastTag.AsUInt32)
                        {
                            // Add entry with existing attribute.
                            ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                            nextAttributes.CompareRule.Add(validationRuleDicomAttribute);
                            DicomAttribute dicomAttribute = new DicomAttribute(attributeOnly, validationRuleDicomAttribute);
                            nextAttributes.Add(dicomAttribute);

                            // This attribute will be returned. Increase the attribute index.
                            this.currentAttributeIndices[index] = attributeSetIndex + 1;
                        }
                        else
                        {
                            // Add entry with non-existing attribute.
                            ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                            DicomAttribute dicomAttribute = new DicomAttribute(new DvtkHighLevelInterface.Dicom.Other.InvalidAttribute(), validationRuleDicomAttribute);
                            nextAttributes.Add(dicomAttribute);
                        }
                    }
                    else
                        // No more unprocessed attributes left in this dataset.
                    {
                        // Add entry with non-existing attribute.
                        ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                        DicomAttribute dicomAttribute = new DicomAttribute(new DvtkHighLevelInterface.Dicom.Other.InvalidAttribute(), validationRuleDicomAttribute);
                        nextAttributes.Add(dicomAttribute);
                    }
                }
            }

            return(nextAttributes);
        }
Exemple #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="attributeOnly">The attribute without the validation rule.</param>
 /// <param name="validationRuleDicomAttribute">The validation rule that needs to be applied to the attribute.</param>
 public DicomAttribute(DvtkHighLevelInterface.Dicom.Other.Attribute attributeOnly, ValidationRuleDicomAttribute validationRuleDicomAttribute) : base(validationRuleDicomAttribute)
 {
     this.attributeOnly = attributeOnly;
 }
Exemple #3
0
        /// <summary>
        /// Get the next list of attributes to compare to each other.
        /// If an attribute is not present, a null pointer is returned in the AttributeCollection.
        /// If all attributes have been compared, null is returned.
        /// </summary>
        /// <returns>The attributes to compare.</returns>



        public AttributeList GetNextAttributes()
        {
            AttributeList nextAttributes = null;

            if (this.compareRulesIndex >= this.compareRules.Count)
            {
                nextAttributes = null;
            }
            else
            {
                nextAttributes = new AttributeList();

                CompareRule compareRule = this.compareRules[this.compareRulesIndex] as CompareRule;

                nextAttributes.CompareRule = compareRule;

                // Use the attributeCollectionsIndex to iterate through both the attributeCollections and compareRule.
                for (int validationRuleListIndex = 0; validationRuleListIndex < compareRule.Count; validationRuleListIndex++)
                {
                    ValidationRuleBase validationRule = compareRule[validationRuleListIndex];

                    if (validationRule is ValidationRuleDicomAttribute)
                    {
                        ValidationRuleDicomAttribute validationRuleDicomAttribute = validationRule as ValidationRuleDicomAttribute;
                        DicomAttributeCollection     dicomAttributeCollection     = this.attributeCollections[validationRuleListIndex] as DicomAttributeCollection;

                        DicomAttribute dicomAttribute = null;

                        if (validationRuleDicomAttribute == null)
                        // If nothing needs to be validated.
                        {
                            dicomAttribute = null;
                        }
                        else
                        {
                            DvtkHighLevelInterface.Dicom.Other.Attribute dicomAttributeOnly = null;

                            if (dicomAttributeCollection.AttributeSetOnly.Exists(validationRuleDicomAttribute.TagSequenceString))
                            {
                                dicomAttributeOnly = dicomAttributeCollection.AttributeSetOnly[validationRuleDicomAttribute.TagSequenceString];
                            }
                            else
                            {
                                dicomAttributeOnly = new InvalidAttribute();
                            }

                            // Merge the validation flags from the validation rule and the attribute collection.
                            ValidationRuleDicomAttribute mergedValidationRuleDicomAttribute = new ValidationRuleDicomAttribute(validationRuleDicomAttribute.TagSequenceString, validationRuleDicomAttribute.Flags | dicomAttributeCollection.Flags);

                            dicomAttribute = new DicomAttribute(dicomAttributeOnly, mergedValidationRuleDicomAttribute);

                            dicomAttribute.DisplayFullTagSequence = true;
                        }

                        nextAttributes.Add(dicomAttribute);
                    }
                    else if (validationRule is ValidationRuleHl7Attribute)
                    {
                        ValidationRuleHl7Attribute validationRuleHl7Attribute = validationRule as ValidationRuleHl7Attribute;
                        Hl7AttributeCollection     hl7AttributeCollection     = this.attributeCollections[validationRuleListIndex] as Hl7AttributeCollection;

                        Hl7Attribute hl7Attribute = null;

                        if (validationRuleHl7Attribute == null)
                        // If nothing needs to be validated.
                        {
                            hl7Attribute = null;
                        }
                        else
                        {
                            // Merge the validation flags from the validation rule and the attribute collection.
                            ValidationRuleHl7Attribute mergedValidationRuleHl7Attribute = new ValidationRuleHl7Attribute(validationRuleHl7Attribute.Hl7Tag, validationRuleHl7Attribute.Flags | hl7AttributeCollection.Flags);

                            hl7Attribute = new Hl7Attribute(hl7AttributeCollection.Hl7MessageOnly.Value(validationRuleHl7Attribute.Hl7Tag), mergedValidationRuleHl7Attribute);
                        }

                        nextAttributes.Add(hl7Attribute);
                    }
                    else
                    {
                        nextAttributes.Add(null);
                    }
                }

                this.compareRulesIndex++;
            }

            return(nextAttributes);
        }
Exemple #4
0
        //
        // - Methods -
        //

        /// <summary>
        /// Get the next collection of attributes to compare to each other.
        /// If an attribute is not present, a null pointer is returned in the AttributeCollection.
        /// If all attributes have been compared, null is returned.
        /// </summary>
        /// <returns>The attributes to validate.</returns>
        ///



        private AttributeList DetermineNextAttributes(TagSequence lowestTagSequence)
        {
            AttributeList nextAttributes = new AttributeList();

            nextAttributes.CompareRule = new CompareRule();

            for (int index = 0; index < this.attributeCollections.Count; index++)
            {
                int attributeSetIndex = (int)this.currentAttributeIndices[index];
                AttributeCollectionBase attributeCollectionBase = this.attributeCollections[index];

                if (attributeCollectionBase == null)
                {
                    nextAttributes.Add(null);
                    nextAttributes.CompareRule.Add(null);
                }
                else if (attributeCollectionBase is Hl7AttributeCollection)
                {
                    nextAttributes.Add(null);
                    nextAttributes.CompareRule.Add(null);
                }
                else if (attributeCollectionBase is DicomAttributeCollection)
                {
                    DicomAttributeCollection dicomAttributeCollection = attributeCollectionBase as DicomAttributeCollection;

                    if (attributeSetIndex < dicomAttributeCollection.AttributeSetOnly.Count)
                    // Still unprocessed attributes left in this dataset.
                    {
                        ValidAttribute attributeOnly = dicomAttributeCollection.AttributeSetOnly[attributeSetIndex] as ValidAttribute;

                        if (attributeOnly.TagSequence.LastTag.AsUInt32 == lowestTagSequence.LastTag.AsUInt32)
                        {
                            // Add entry with existing attribute.
                            ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                            nextAttributes.CompareRule.Add(validationRuleDicomAttribute);
                            DicomAttribute dicomAttribute = new DicomAttribute(attributeOnly, validationRuleDicomAttribute);
                            nextAttributes.Add(dicomAttribute);

                            // This attribute will be returned. Increase the attribute index.
                            this.currentAttributeIndices[index] = attributeSetIndex + 1;
                        }
                        else
                        {
                            // Add entry with non-existing attribute.
                            ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                            DicomAttribute dicomAttribute = new DicomAttribute(new DvtkHighLevelInterface.Dicom.Other.InvalidAttribute(), validationRuleDicomAttribute);
                            nextAttributes.Add(dicomAttribute);
                        }
                    }
                    else
                    // No more unprocessed attributes left in this dataset.
                    {
                        // Add entry with non-existing attribute.
                        ValidationRuleDicomAttribute validationRuleDicomAttribute = new ValidationRuleDicomAttribute(lowestTagSequence.ToString(), dicomAttributeCollection.Flags);
                        DicomAttribute dicomAttribute = new DicomAttribute(new DvtkHighLevelInterface.Dicom.Other.InvalidAttribute(), validationRuleDicomAttribute);
                        nextAttributes.Add(dicomAttribute);
                    }
                }
            }

            return(nextAttributes);
        }
Exemple #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="attributeOnly">The attribute without the validation rule.</param>
 /// <param name="validationRuleDicomAttribute">The validation rule that needs to be applied to the attribute.</param>
 public DicomAttribute(DvtkHighLevelInterface.Dicom.Other.Attribute attributeOnly, ValidationRuleDicomAttribute validationRuleDicomAttribute)
     : base(validationRuleDicomAttribute)
 {
     this.attributeOnly = attributeOnly;
 }