Esempio n. 1
0
        /// <summary>
        /// Compare the two messages.
        /// </summary>
        /// <param name="resultsReporter">Results reporter.</param>
        /// <param name="thatBaseComparator">Reference comparator.</param>
        /// <returns>bool - true = messages compared, false messages not compared</returns>
        public override bool Compare(ResultsReporter resultsReporter, BaseComparator thatBaseComparator)
        {
            bool compared = false;

            if (thatBaseComparator is DicomComparator)
            {
                DicomComparator thatDicomComparator = (DicomComparator)thatBaseComparator;

                // Check if both templates have been initialized correctly
                if ((this._template == null) ||
                    (thatDicomComparator._template == null))
                {
                    return false;
                }

                // Check for comparator equality
                if (this == thatDicomComparator)
                {
                    return true;
                }

                MessageComparisonResults messageComparisonResults
                    = new MessageComparisonResults(this._name,
                                                thatDicomComparator._name,
                                                this._template.Command,
                                                thatDicomComparator._template.Command,
                                                this._template.SopClassUid,
                                                thatDicomComparator._template.SopClassUid);

                // Iterate over this comparator
                foreach (DicomComparisonTag thisComparisonTag in this._template.ComparisonTags)
                {
                    // try to get the equivalent tag in thatDicomComparator
                    DicomComparisonTag thatComparisonTag = thatDicomComparator._template.ComparisonTags.Find(thisComparisonTag.Tag);
                    if (thatComparisonTag != null)
                    {
                        AttributeComparisonResults attributeComparisonResults
                            = new AttributeComparisonResults(thisComparisonTag.Tag,
                                                            thisComparisonTag.DataFormat.ToDicomFormat(),
                                                            thatComparisonTag.DataFormat.ToDicomFormat());

                        if (thisComparisonTag.DataFormat.Equals(thatComparisonTag.DataFormat) == false)
                        {
                            DvtkData.Validation.ValidationMessage validationMessage = new DvtkData.Validation.ValidationMessage();
                            validationMessage.Type = DvtkData.Validation.MessageType.Error;
                            validationMessage.Message = "Attribute values do not match.";

                            attributeComparisonResults.Messages.Add(validationMessage);
                        }
                        messageComparisonResults.Add(attributeComparisonResults);
                    }
                }

                resultsReporter.WriteMessageComparisonResults(messageComparisonResults);

                compared = true;
            }

            return compared;
        }
Esempio n. 2
0
        /// <summary>
        /// Compare the two messages.
        /// </summary>
        /// <param name="tagValueFilterCollection">Tag Value Filter.</param>
        /// <param name="resultsReporter">Results reporter.</param>
        /// <param name="thatBaseComparator">Reference comparator.</param>
        /// <returns>bool - true = messages compared, false messages not compared</returns>
        public override bool Compare(TagValueCollection tagValueFilterCollection, ResultsReporter resultsReporter, BaseComparator thatBaseComparator)
        {
            bool compared = false;

            if (thatBaseComparator is DicomComparator)
            {
                DicomComparator thatDicomComparator = (DicomComparator)thatBaseComparator;

                // Check if both templates have been initialized correctly
                if ((this.Template == null) ||
                    (thatDicomComparator.Template == null))
                {
                    return false;
                }

                // Check for comparator equality
                if (this == thatDicomComparator)
                {
                    return true;
                }

                // filter out comparators for the same message types
                if ((this.Template.Command == thatDicomComparator.Template.Command) &&
                    (this.Template.SopClassUid == thatDicomComparator.Template.SopClassUid))
                {
                    return false;
                }

                // generate a local Tag Value collection from this
                // - this collection will include any tag value pair from the original collection and
                // the tag value pairs of any tags only (in the original collection) that match from this
                // comparator - that is the values are taken from this comparator.
                TagValueCollection lTagValueFilterCollection = GenerateTagValueCollection(tagValueFilterCollection);

                // check to see if the comparision filters match - without Univeral Matching
                // - now try to match this local filter collection against thatDicomComparator
                // - comparators that match will have the same tag value pairs (including the value) as
                // each other.
                if ((tagValueFilterCollection.Count == lTagValueFilterCollection.Count) &&
                    (thatDicomComparator.UseComparator(lTagValueFilterCollection, false) == true))
                {
                    MessageComparisonResults messageComparisonResults
                        = new MessageComparisonResults(this.Name,
                        thatDicomComparator.Name,
                        this.Template.Command,
                        thatDicomComparator.Template.Command,
                        this.Template.SopClassUid,
                        thatDicomComparator.Template.SopClassUid);

                    // Iterate over this comparator
                    foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // try to get the equivalent tag in thatDicomComparator
                        DicomComparisonTag thatComparisonTag = thatDicomComparator.Template.ComparisonTags.Find(thisComparisonTag.Tag);
                        if (thatComparisonTag != null)
                        {
                            AttributeComparisonResults attributeComparisonResults
                                = new AttributeComparisonResults(thisComparisonTag.Tag,
                                thisComparisonTag.DataFormat.ToDicomFormat(),
                                thatComparisonTag.DataFormat.ToDicomFormat());

                            if (thisComparisonTag.DataFormat.Equals(thatComparisonTag.DataFormat) == false)
                            {
                                DvtkData.Validation.ValidationMessage validationMessage = new DvtkData.Validation.ValidationMessage();
                                validationMessage.Type = DvtkData.Validation.MessageType.Error;
                                validationMessage.Message = "Attribute values do not match.";

                                attributeComparisonResults.Messages.Add(validationMessage);
                            }
                            messageComparisonResults.Add(attributeComparisonResults);
                        }
                    }

                    resultsReporter.WriteMessageComparisonResults(messageComparisonResults);

                    compared = true;
                }
            }
            else if (thatBaseComparator is Hl7Comparator)
            {
                Hl7Comparator thatHl7Comparator = (Hl7Comparator)thatBaseComparator;

                // Check if both templates have been initialized correctly
                if ((this.Template == null) ||
                    (thatHl7Comparator.Template == null))
                {
                    return false;
                }

                // generate a local Tag Value collection from this
                // - this collection will include any tag value pair from the original collection and
                // the tag value pairs of any tags only (in the original collection) that match from this
                // comparator - that is the values are taken from this comparator.
                TagValueCollection lTagValueFilterCollection = GenerateTagValueCollection(tagValueFilterCollection);

                // check to see if the comparision filters match - without Univeral Matching
                // - now try to match this local filter collection against thatDicomComparator
                // - comparators that match will have the same tag value pairs (including the value) as
                // each other.
                if ((tagValueFilterCollection.Count == lTagValueFilterCollection.Count) &&
                    (thatHl7Comparator.UseComparator(lTagValueFilterCollection, false) == true))
                {
                    MessageComparisonResults messageComparisonResults
                        = new MessageComparisonResults(this.Name,
                        thatHl7Comparator.Name,
                        this.Template.Command,
                        thatHl7Comparator.Template.MessageType,
                        this.Template.SopClassUid,
                        thatHl7Comparator.Template.MessageSubType);

                    // Iterate over this comparator
                    foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // try to get the equivalent tag in thatHl7Comparator
                        Hl7ComparisonTag thatComparisonTag = thatHl7Comparator.Template.ComparisonTags.Find(DicomHl7TagMapTemplate.DicomToHl7Tag(thisComparisonTag.Tag));
                        if (thatComparisonTag != null)
                        {
                            AttributeComparisonResults attributeComparisonResults
                                = new AttributeComparisonResults(thisComparisonTag.Tag,
                                SegmentNames.Name(thatComparisonTag.Tag.Segment),
                                thatComparisonTag.Tag.FieldIndex,
                                thisComparisonTag.DataFormat.ToDicomFormat(),
                                thatComparisonTag.DataFormat.ToHl7Format());

                            if (thisComparisonTag.DataFormat.Equals(thatComparisonTag.DataFormat) == false)
                            {
                                DvtkData.Validation.ValidationMessage validationMessage = new DvtkData.Validation.ValidationMessage();
                                validationMessage.Type = DvtkData.Validation.MessageType.Error;
                                validationMessage.Message = "Attribute values do not match.";

                                attributeComparisonResults.Messages.Add(validationMessage);
                            }
                            messageComparisonResults.Add(attributeComparisonResults);
                        }
                    }

                    resultsReporter.WriteMessageComparisonResults(messageComparisonResults);

                    compared = true;
                }
            }

            return compared;
        }
Esempio n. 3
0
 /// <summary>
 /// Removes the first occurrence of a specific <see cref="AttributeComparisonResults"/> from the <see cref="MessageComparisonResults"/>.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to remove from the <see cref="MessageComparisonResults"/>.</param>
 public void Remove(AttributeComparisonResults value)
 {
     List.Remove(value);
 }
Esempio n. 4
0
 /// <summary>
 /// Determines whether the <see cref="MessageComparisonResults"/> contains a specific element.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to locate in the <see cref="MessageComparisonResults"/>.</param>
 /// <returns>
 /// <c>true</c> if the <see cref="MessageComparisonResults"/> contains the specified value;
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AttributeComparisonResults value)
 {
     // If value is not of type Code, this will return false.
     return(List.Contains(value));
 }
Esempio n. 5
0
 /// <summary>
 /// Searches for the specified <see cref="AttributeComparisonResults"/> and
 /// returns the zero-based index of the first occurrence within the entire <see cref="MessageComparisonResults"/>.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to locate in the <see cref="MessageComparisonResults"/>.</param>
 /// <returns>
 /// The zero-based index of the first occurrence of value within the entire <see cref="MessageComparisonResults"/>,
 /// if found; otherwise, -1.
 /// </returns>
 public int IndexOf(AttributeComparisonResults value)
 {
     return(List.IndexOf(value));
 }
Esempio n. 6
0
 /// <summary>
 /// Inserts an <see cref="AttributeComparisonResults"/> element into the <see cref="MessageComparisonResults"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The <see cref="MessageComparisonResults"/> to insert.</param>
 public void Insert(int index, AttributeComparisonResults value)
 {
     List.Insert(index, value);
 }
Esempio n. 7
0
 /// <summary>
 /// Removes the first occurrence of a specific <see cref="AttributeComparisonResults"/> from the <see cref="MessageComparisonResults"/>.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to remove from the <see cref="MessageComparisonResults"/>.</param>
 public void Remove(AttributeComparisonResults value)
 {
     List.Remove(value);
 }
Esempio n. 8
0
 /// <summary>
 /// Adds an object to the end of the <see cref="MessageComparisonResults"/>.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to be added to the end of the <see cref="MessageComparisonResults"/>.</param>
 /// <returns>The <see cref="MessageComparisonResults"/> index at which the value has been added.</returns>
 public int Add(AttributeComparisonResults value)
 {
     return(List.Add(value));
 }
Esempio n. 9
0
 /// <summary>
 /// Inserts an <see cref="AttributeComparisonResults"/> element into the <see cref="MessageComparisonResults"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The <see cref="MessageComparisonResults"/> to insert.</param>
 public void Insert(int index, AttributeComparisonResults value)
 {
     List.Insert(index, value);
 }
Esempio n. 10
0
 /// <summary>
 /// Searches for the specified <see cref="AttributeComparisonResults"/> and 
 /// returns the zero-based index of the first occurrence within the entire <see cref="MessageComparisonResults"/>.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to locate in the <see cref="MessageComparisonResults"/>.</param>
 /// <returns>
 /// The zero-based index of the first occurrence of value within the entire <see cref="MessageComparisonResults"/>, 
 /// if found; otherwise, -1.
 /// </returns>
 public int IndexOf(AttributeComparisonResults value)
 {
     return (List.IndexOf(value));
 }
Esempio n. 11
0
 /// <summary>
 /// Copies the elements of the <see cref="ICollection"/> to a strong-typed <c>AttributeComparisonResults[]</c>, 
 /// starting at a particular <c>AttributeComparisonResults[]</c> index.
 /// </summary>
 /// <param name="array">
 /// The one-dimensional <c>AttributeComparisonResults[]</c> that is the destination of the elements 
 /// copied from <see cref="ICollection"/>.
 /// The <c>AttributeComparisonResults[]</c> must have zero-based indexing. 
 /// </param>
 /// <param name="index">
 /// The zero-based index in array at which copying begins.
 /// </param>
 /// <remarks>
 /// Provides the strongly typed member for <see cref="ICollection"/>.
 /// </remarks>
 public void CopyTo(AttributeComparisonResults[] array, int index)
 {
     ((ICollection)this).CopyTo(array, index);
 }
Esempio n. 12
0
 /// <summary>
 /// Determines whether the <see cref="MessageComparisonResults"/> contains a specific element.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to locate in the <see cref="MessageComparisonResults"/>.</param>
 /// <returns>
 /// <c>true</c> if the <see cref="MessageComparisonResults"/> contains the specified value; 
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AttributeComparisonResults value)
 {
     // If value is not of type Code, this will return false.
     return (List.Contains(value));
 }
Esempio n. 13
0
 /// <summary>
 /// Adds an object to the end of the <see cref="MessageComparisonResults"/>.
 /// </summary>
 /// <param name="value">The <see cref="AttributeComparisonResults"/> to be added to the end of the <see cref="MessageComparisonResults"/>.</param>
 /// <returns>The <see cref="MessageComparisonResults"/> index at which the value has been added.</returns>
 public int Add(AttributeComparisonResults value)
 {
     return (List.Add(value));
 }