Ejemplo n.º 1
0
        private static ArrayList FilterOnDicomOBOWOF(ArrayList attributes)
        {
            ArrayList filteredAttributes = new ArrayList();

            foreach (AttributeBase attribute in attributes)
            {
                if (attribute is DicomAttribute)
                {
                    DicomAttribute dicomAttribute = attribute as DicomAttribute;

                    if ((dicomAttribute.AttributeOnly.VR == VR.OB) || (dicomAttribute.AttributeOnly.VR == VR.OW) || (dicomAttribute.AttributeOnly.VR == VR.OF))
                    {
                        filteredAttributes.Add(attribute);
                    }
                }
            }

            return(filteredAttributes);
        }
Ejemplo n.º 2
0
        private void SetNameCellForDicomAttribute(DicomAttribute dicomAttribute, int columnIndex)
        {
            if (dicomAttribute != null)
            {
                if (dicomAttribute.IsPresent)
                {
                    String name = "-";

                    if ((dicomAttribute.AttributeOnly.Name != "") && !(dicomAttribute.AttributeOnly.Name.StartsWith(" : private mapped to")))
                    {
                        name = "\"" + dicomAttribute.AttributeOnly.Name + "\"";
                    }

                    SetCellOK(columnIndex, name);
                }
                else
                {
                    SetCellOK(columnIndex, "-");
                }
            }
        }
Ejemplo n.º 3
0
        // Precondition: DicomAttribute.
        private void SetPresentCellForDicomBeginOrEndSequenceItem(AttributeList attributeList, int zeroBasedAttributesIndex, int sequenceItemIndex, bool isBeginItem)
        {
            int columnIndex = (int)this.columnIndexAttributePresent[zeroBasedAttributesIndex];

            DicomAttribute dicomAttribute = attributeList[zeroBasedAttributesIndex] as DicomAttribute;

            String presentText = "";

            if (dicomAttribute.IsPresent)
            {
                if (dicomAttribute.AttributeOnly.VR == VR.SQ)
                {
                    if (sequenceItemIndex > dicomAttribute.AttributeOnly.ItemCount)
                    {
                        presentText = "-";
                    }
                    else
                    {
                        presentText = "+";
                    }
                }
                else
                {
                    presentText = "-";
                }
            }
            else
            {
                presentText = "-";
            }

            if (attributeList.DicomContainsCompareSequenceItemsErrors(sequenceItemIndex))
            {
                SetCellError(columnIndex, presentText);
            }
            else
            {
                SetCellOK(columnIndex, presentText);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 // Precondition: DicomAttribute.
 private void SetNameCellForDicomBeginOrEndSequenceItem(DicomAttribute dicomAttribute, int sequenceItemIndex, bool isBeginItem, int columnIndex)
 {
     if (dicomAttribute.IsPresent)
     {
         if (dicomAttribute.AttributeOnly.VR == VR.SQ)
         {
             if (sequenceItemIndex <= dicomAttribute.AttributeOnly.ItemCount)
             {
                 SetCellOK(columnIndex, "Item " + sequenceItemIndex.ToString());
             }
         }
     }
 }
Ejemplo n.º 7
0
        private void SetNameCellForDicomAttribute(DicomAttribute dicomAttribute, int columnIndex)
        {
            if (dicomAttribute != null)
            {
                if (dicomAttribute.IsPresent)
                {
                    String name = "-";

                    if ((dicomAttribute.AttributeOnly.Name != "") && !(dicomAttribute.AttributeOnly.Name.StartsWith(" : private mapped to")))
                    {
                        name = "\"" + dicomAttribute.AttributeOnly.Name + "\"";
                    }

                    SetCellOK(columnIndex, name);
                }
                else
                {
                    SetCellOK(columnIndex, "-");
                }
            }
        }
Ejemplo n.º 8
0
        // Precondition: DicomAttribute.
        private void SetTagCellForDicomBeginOrEndSequenceItem(DicomAttribute dicomAttribute, int sequenceItemIndex, bool isBeginItem, int columnIndex)
        {
            if (dicomAttribute.IsPresent)
            {
                if (dicomAttribute.AttributeOnly.VR == VR.SQ)
                {
                    if (sequenceItemIndex <= dicomAttribute.AttributeOnly.ItemCount)
                    {
                        int level = (dicomAttribute.AttributeOnly as ValidAttribute).TagSequence.Tags.Count;

                        String tagText = "";

                        if (isBeginItem)
                        {
                            tagText = "".PadRight(level, '>') + "BEGIN ITEM";
                        }
                        else
                        {
                            tagText = "".PadRight(level, '>') + "END ITEM";
                        }

                        SetCellOK(columnIndex, tagText);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        //
        // - Methods -
        //
        private void SetTagCellForDicomAttribute(DicomAttribute dicomAttribute, int columnIndex)
        {
            if (dicomAttribute != null)
            {
                TagSequence tagSequence = new TagSequence(dicomAttribute.ValidationRuleDicomAttribute.TagSequenceString);

                if (dicomAttribute.DisplayFullTagSequence)
                {
                    ArrayList tags = tagSequence.Tags;

                    for (int tagIndex = 0; tagIndex < tags.Count; tagIndex++)
                    {
                        Tag tag = tags[tagIndex] as Tag;
                        if (tag.ContainsIndex)
                        {
                            SetCellOK(columnIndex, "".PadRight(tagIndex, '>') + tag.DicomNotation + "(" + tag.IndexNumber + ")");
                        }
                        else
                        {
                            SetCellOK(columnIndex, "".PadRight(tagIndex, '>') + tag.DicomNotation);
                        }
                    }
                }
                else
                {
                    SetCellOK(columnIndex, tagSequence.DicomNotation);
                }
            }

            if (this.displayFlags)
            {
                SetCellOK(columnIndex, "<br><i>Flags:</i>");
                SetCellOK(columnIndex, "<i>" + dicomAttribute.ValidationRule.FlagsString + "</i>");
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        private void AddAttributesInformation(AttributeList attributeList)
        {
            NewRow();


            //
            // Fill in the common information.
            //

            if (this.displayCommonTag)
            {
                SetTagCellForDicomAttribute(attributeList.LeadingDicomAttribute, this.columnIndexCommonTag);
            }

            if (this.displayCommonName)
            {
                SetNameCellForDicomAttribute(attributeList.LeadingDicomAttribute, this.columnIndexCommonName);
            }


            //
            // Fill in the information specific for each attribute.
            //

            for (int attributeIndex = 0; attributeIndex < attributeList.Count; attributeIndex++)
            {
                // Attribute Tag column.
                if (this.displayAttributeTag)
                {
                    if (attributeList[attributeIndex] is DicomAttribute)
                    {
                        DicomAttribute dicomAttribute = attributeList[attributeIndex] as DicomAttribute;

                        int columnIndex = (int)this.columnIndexAttributeTag[attributeIndex];

                        SetTagCellForDicomAttribute(dicomAttribute, columnIndex);
                    }
                    else if (attributeList[attributeIndex] is Hl7Attribute)
                    {
                        SetTagCellForHl7Attribute(attributeList, attributeIndex);
                    }
                }

                // Attribute Name column.
                if (this.displayAttributeName)
                {
                    if (attributeList[attributeIndex] is DicomAttribute)
                    {
                        DicomAttribute dicomAttribute = attributeList[attributeIndex] as DicomAttribute;

                        int columnIndex = (int)this.columnIndexAttributeName[attributeIndex];

                        SetNameCellForDicomAttribute(dicomAttribute, columnIndex);
                    }
                }

                // Attribute Present column.
                if (this.displayAttributePresent && (attributeList[attributeIndex] != null))
                {
                    SetPresentCellForAttribute(attributeList, attributeIndex);
                }

                // Attribute VR column.
                if (this.displayAttributeVR)
                {
                    if (attributeList[attributeIndex] is DicomAttribute)
                    {
                        SetVrCellForDicomAttribute(attributeList, attributeIndex);
                    }
                }

                // Attribute Values column.
                if (this.displayAttributeValues && (attributeList[attributeIndex] != null))
                {
                    SetValuesCellForAttribute(attributeList, attributeIndex);
                }
            }


            // Fill in the Comments.
            if (this.displayComments && (attributeList.CompareRule != null))
            {
                SetCommentsCell(attributeList.CompareRule);
            }


            //
            // If at least one attribute is a Dicom sequence attribute, do a comparison of the content.
            //

            if (attributeList.DicomContainsSequenceAttribute)
            {
                AddSequenceAttributesContentInformation(attributeList);
            }
        }
Ejemplo n.º 12
0
        private void SetValuesCellForAttribute(AttributeList attributeList, int zeroBasedIndex)
        {
            int columnIndex = (int)this.columnIndexAttributeValues[zeroBasedIndex];

            AttributeBase attributebase = attributeList[zeroBasedIndex];

            if (attributebase.IsPresent)
            {
                bool isDicomSequenceAttribute = false;

                if (attributebase is DicomAttribute)
                {
                    if ((attributebase as DicomAttribute).AttributeOnly.VR == VR.SQ)
                    {
                        isDicomSequenceAttribute = true;
                    }
                }

                if (!isDicomSequenceAttribute)
                {
                    bool containsError = false;

                    String valuesString = attributebase.ValuesToString();

                    if ((attributebase.ValidationRule.Flags & FlagsBase.Compare_values) == FlagsBase.Compare_values)
                    {
                        if (attributeList.ContainsCompareValuesErrors)
                        {
                            containsError = true;
                        }
                    }

                    if ((attributebase.ValidationRule.Flags & FlagsBase.Values) == FlagsBase.Values)
                    {
                        if (valuesString.Length == 0)
                        {
                            containsError = true;
                        }
                    }

                    if ((attributebase.ValidationRule.Flags & FlagsBase.No_values) == FlagsBase.No_values)
                    {
                        if (valuesString.Length > 0)
                        {
                            containsError = true;
                        }
                    }

                    // If this is a Dicom attribute which is a group length, only compare when the compareGroupLength
                    // field is true.
                    if ((!this.displayGroupLength) && (attributebase is DicomAttribute))
                    {
                        DicomAttribute dicomAttribute = attributebase as DicomAttribute;

                        TagSequence tagSequence = new TagSequence(dicomAttribute.ValidationRuleDicomAttribute.TagSequenceString);

                        if (tagSequence.LastTag.ElementNumber == 0)
                        {
                            containsError = false;
                        }
                    }

                    // If the attribute contains no values, display this with the text "No values" in italic.
                    if (valuesString.Length == 0)
                    {
                        valuesString = "<i>No values</i>";
                    }

                    if (containsError)
                    {
                        SetCellError(columnIndex, valuesString);
                    }
                    else
                    {
                        SetCellOK(columnIndex, valuesString);
                    }
                }
                else
                // Is Sequence attribute.
                {
                    if ((attributebase.ValidationRule.Flags & FlagsBase.Include_sequence_items) == 0)
                    // If sequence item will not be displayed.
                    {
                        SetCellOK(columnIndex, "<i>Items will not be displayed.</i>");
                    }
                }
            }
        }
Ejemplo n.º 13
0
        private void SetPresentCellForAttribute(AttributeList attributeList, int zeroBasedIndex)
        {
            int columnIndex = (int)this.columnIndexAttributePresent[zeroBasedIndex];

            AttributeBase attributebase = attributeList[zeroBasedIndex];

            if (attributebase != null)
            {
                String presentString = "";
                bool   containsError = false;

                if (attributebase.IsPresent)
                {
                    presentString = "+";
                }
                else
                {
                    presentString = "-";
                }

                if ((attributebase.ValidationRule.Flags & FlagsBase.Compare_present) == FlagsBase.Compare_present)
                {
                    if (attributeList.ContainsComparePresentErrors)
                    {
                        containsError = true;
                    }
                }

                if ((attributebase.ValidationRule.Flags & FlagsBase.Present) == FlagsBase.Present)
                {
                    if (!attributebase.IsPresent)
                    {
                        containsError = true;
                    }
                }

                if ((attributebase.ValidationRule.Flags & FlagsBase.Not_present) == FlagsBase.Not_present)
                {
                    if (attributebase.IsPresent)
                    {
                        containsError = true;
                    }
                }

                // If this is a Dicom attribute which is a group length, only compare when the compareGroupLength
                // field is true.
                if ((!this.displayGroupLength) && (attributebase is DicomAttribute))
                {
                    DicomAttribute dicomAttribute = attributebase as DicomAttribute;

                    TagSequence tagSequence = new TagSequence(dicomAttribute.ValidationRuleDicomAttribute.TagSequenceString);

                    if (tagSequence.LastTag.ElementNumber == 0)
                    {
                        containsError = false;
                    }
                }

                if (containsError)
                {
                    SetCellError(columnIndex, presentString);
                }
                else
                {
                    SetCellOK(columnIndex, presentString);
                }
            }
        }
Ejemplo n.º 14
0
        private void AddSequenceAttributesContentInformation(AttributeList attributeList)
        {
            //
            // Determine the maximum amount of sequence items for all supplied sequence attributes
            // that have the include_sequence_items flag enabled.
            //

            int maxItemCount = attributeList.DicomMaxItemCount;


            //
            // Fill the table with the information.
            //

            for (int itemIndex = 1; itemIndex <= maxItemCount; itemIndex++)
            {
                //
                // Add begin item row.
                //

                AddSequenceItemRow(attributeList, itemIndex, true);


                //
                // Add the comparison of attributes within the sequence items.
                //

                AttributeCollections attributeCollections = new AttributeCollections();

                for (int attributeIndex = 0; attributeIndex < attributeList.Count; attributeIndex++)
                {
                    if (attributeList[attributeIndex] == null)
                    {
                        attributeCollections.AddNull();
                    }
                    else if (attributeList[attributeIndex] is Hl7Attribute)
                    {
                        attributeCollections.AddNull();
                    }
                    else if (attributeList[attributeIndex] is DicomAttribute)
                    {
                        DicomAttribute dicomAttribute = attributeList[attributeIndex] as DicomAttribute;

                        if ((dicomAttribute.ValidationRule.Flags & FlagsBase.Include_sequence_items) == FlagsBase.Include_sequence_items)
                        {
                            if (dicomAttribute.AttributeOnly is ValidAttribute)
                            // Attribute is valid attribute.
                            {
                                ValidAttribute validAttribute = dicomAttribute.AttributeOnly as ValidAttribute;

                                if (validAttribute.VR == VR.SQ)
                                // Attribute is valid SQ attribute.
                                {
                                    if (validAttribute.ItemCount < itemIndex)
                                    {
                                        // Item index to high for actual item count.
                                        attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                                    }
                                    else
                                    // Item exists.
                                    {
                                        attributeCollections.Add(new DicomAttributeCollection(validAttribute.GetItem(itemIndex), dicomAttribute.ValidationRule.Flags));
                                    }
                                }
                                else
                                // Attribute is valid attribute but not a SQ attribute.
                                {
                                    attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                                }
                            }
                            else
                            // Attribute does not exist.
                            {
                                attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                            }
                        }
                        else
                        // Flags specify sequence items must not be included.
                        {
                            attributeCollections.AddNull();
                        }
                    }
                }

                AddAttributeCollectionsInformationUsingStaticDicomCompare(attributeCollections);


                //
                // Add end item row.
                //

                AddSequenceItemRow(attributeList, itemIndex, false);
            }
        }
Ejemplo n.º 15
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);
        }