Exemplo 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);
        }
Exemplo 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;
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
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 Hl7Comparator)
            {
                Hl7Comparator thatHl7Comparator = (Hl7Comparator)thatBaseComparator;

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

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

                // filter out comparators for the same message types
                if ((this.Template.MessageType == thatHl7Comparator.Template.MessageType) &&
                    (this.Template.MessageSubType == thatHl7Comparator.Template.MessageSubType))
                {
                    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.MessageType,
                                                       thatHl7Comparator.Template.MessageType,
                                                       this.Template.MessageSubType,
                                                       thatHl7Comparator.Template.MessageSubType);

                    // Iterate over this comparator
                    foreach (Hl7ComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // try to get the equivalent tag in thatHl7Comparator
                        Hl7ComparisonTag thatComparisonTag = thatHl7Comparator.Template.ComparisonTags.Find(thisComparisonTag.Tag);
                        if (thatComparisonTag != null)
                        {
                            AttributeComparisonResults attributeComparisonResults
                                = new AttributeComparisonResults(SegmentNames.Name(thisComparisonTag.Tag.Segment),
                                                                 thisComparisonTag.Tag.FieldIndex,
                                                                 thisComparisonTag.DataFormat.ToHl7Format(),
                                                                 thatComparisonTag.DataFormat.ToHl7Format());
                            attributeComparisonResults.Name = DicomHl7TagMapTemplate.Hl7NameFromHl7Tag(thisComparisonTag.Tag);
                            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 DicomComparator)
            {
                DicomComparator thatDicomComparator = (DicomComparator)thatBaseComparator;

                // Check if both templates have been initialized correctly
                if ((this.Template == null) ||
                    (thatDicomComparator.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) &&
                    (thatDicomComparator.UseComparator(lTagValueFilterCollection, false) == true))
                {
                    MessageComparisonResults messageComparisonResults
                        = new MessageComparisonResults(this.Name,
                                                       thatDicomComparator.Name,
                                                       this.Template.MessageType,
                                                       thatDicomComparator.Template.Command,
                                                       this.Template.MessageSubType,
                                                       thatDicomComparator.Template.SopClassUid);

                    // Iterate over this comparator
                    foreach (Hl7ComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // try to get the equivalent tag in thatDicomComparator
                        DicomComparisonTag thatComparisonTag = thatDicomComparator.Template.ComparisonTags.Find(DicomHl7TagMapTemplate.Hl7ToDicomTag(thisComparisonTag.Tag));
                        if (thatComparisonTag != null)
                        {
                            AttributeComparisonResults attributeComparisonResults
                                = new AttributeComparisonResults(thatComparisonTag.Tag,
                                                                 SegmentNames.Name(thisComparisonTag.Tag.Segment),
                                                                 thisComparisonTag.Tag.FieldIndex,
                                                                 thisComparisonTag.DataFormat.ToHl7Format(),
                                                                 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);
        }
Exemplo n.º 5
0
        public void SerializeValidationReport(
			Wrappers.WrappedValidationMessageLevel activityReportLevel,
			System.String message)
        {
            if (this.m_parentSession.ResultsGatheringPaused) return;
            if (this.m_serializationWriter == null) return;
            DvtkData.Validation.ValidationMessage validationMessage = new DvtkData.Validation.ValidationMessage();
            switch(activityReportLevel)
            {
                case Wrappers.WrappedValidationMessageLevel.Error:
                    validationMessage.Type = DvtkData.Validation.MessageType.Error;
                    break;
                case Wrappers.WrappedValidationMessageLevel.Warning:
                    validationMessage.Type = DvtkData.Validation.MessageType.Warning;
                    break;
                case Wrappers.WrappedValidationMessageLevel.Information:
                    validationMessage.Type = DvtkData.Validation.MessageType.Info;
                    break;
                case Wrappers.WrappedValidationMessageLevel.ConditionText:
                    validationMessage.Type = DvtkData.Validation.MessageType.ConditionText;
                    break;
                default:
                    validationMessage.Type = DvtkData.Validation.MessageType.Info;
                    break;
            }
            validationMessage.Message = DvtToXml.ConvertString(message,false);

            // stream validation message to detailed output
            validationMessage.DvtDetailToXml(m_serializationWriter.DetailStreamWriter, 0);

            // stream validation message to summary output
            validationMessage.DvtDetailToXml(m_serializationWriter.SummaryStreamWriter, 0);
        }