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 all comparators against eachother.
 /// </summary>
 /// <param name="resultsReporter">Results reporter.</param>
 public void Compare(ResultsReporter resultsReporter)
 {
     for (int i = 0; i < this.Count; i++)
     {
         for (int j = i + 1; j < this.Count; j++)
         {
             this[i].Compare(resultsReporter, this[j]);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Class Constructor.
        /// </summary>
        /// <param name="profileName">Integration Profile Name.</param>
        public IntegrationProfile(System.String profileName)
        {
            _profileName = profileName;
            _actors = new ActorCollection();
            _actorConfigs = new ActorConfigCollection();
            _actorsTransactionLog = new ActorsTransactionLog();
            _applicationDirectory = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

            _resultsReporter = new ResultsReporter(_resultsDirectory);
        }
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 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.º 5
0
        /// <summary>
        /// Evaluate the transaction log results using the associated comparators.
        /// </summary>
        public void Evaluate(ResultsReporter resultsReporter)
        {
            Dvtk.Comparator.BaseComparatorCollection comparatorCollection = new Dvtk.Comparator.BaseComparatorCollection();

            for (int i = 0; i < this.Count; i++)
            {
                foreach (ActorsTransaction actorsTransaction in this)
                {
                    if (actorsTransaction.TransactionNumber == i + 1)
                    {
                        actorsTransaction.SetComparators(comparatorCollection);
                    }
                }
            }

            comparatorCollection.Compare(resultsReporter);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Compare all comparators against eachother.
 /// </summary>
 /// <param name="resultsReporter">Results reporter.</param>
 public void Compare(ResultsReporter resultsReporter)
 {
     for (int i = 0; i < this.Count; i++)
     {
         for (int j = i + 1; j < this.Count; j++)
         {
             this[i].Compare(_tagValueFilterCollection, resultsReporter, this[j]);
         }
     }
 }
Exemplo n.º 7
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 abstract bool Compare(TagValueCollection tagValueFilterCollection, ResultsReporter resultsReporter, BaseComparator thatBaseComparator);
Exemplo n.º 8
0
 /// <summary>
 /// Open the Results reporting.
 /// </summary>
 public void OpenResults()
 {
     // results directory is only defined after loading the configuration
     _resultsReporter = new ResultsReporter(_resultsDirectory);
     _resultsFilename = Config.ProfileName.Replace(" ","") + "ResultsIndex.xml";
     _resultsReporter.Start(_resultsFilename);
 }
Exemplo n.º 9
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 abstract bool Compare(ResultsReporter resultsReporter, BaseComparator thatBaseComparator);
Exemplo n.º 10
0
        /// <summary>
        /// Evaluate the transaction log results using the associated comparators.
        /// </summary>
        /// <param name="resultsReporter">Results reporter.</param>
        public void Evaluate(ResultsReporter resultsReporter)
        {
            ArrayList allActorsTransactions = new ArrayList();

            for (int i = 0; i < this.Count; i++)
            {
                foreach (ActorsTransaction actorsTransaction in this)
                {
                    if (actorsTransaction.TransactionNumber == i + 1)
                    {
                        allActorsTransactions.Add(actorsTransaction);
                    }
                }
            }

            ArrayList ActorsTransactionsToCompare = this.compareCondition.Filter(allActorsTransactions);

            foreach (ActorsTransaction actorsTransaction in ActorsTransactionsToCompare)
            {
                actorsTransaction.SetComparators(_comparatorCollection);
            }

            if (_comparatorCollection.TagValueCollection.Count > 0)
            {
                resultsReporter.WriteHtmlInformation("<h2>Message Comparison</h2>");
                resultsReporter.WriteValidationInformation("Comparators Filtered on:");
                foreach(DicomTagValue tagValue in _comparatorCollection.TagValueCollection)
                {
                    string group = tagValue.Tag.GroupNumber.ToString("X").PadLeft(4, '0');
                    string element = tagValue.Tag.ElementNumber.ToString("X").PadLeft(4, '0');
                    System.String message;
                    if (tagValue.Value == System.String.Empty)
                    {
                        message = System.String.Format("Attribute Tag: ({0},{1}) - Value: Universal Match",
                            group,
                            element);
                    }
                    else
                    {
                        message = System.String.Format("Attribute Tag: ({0},{1}) - Value: \"{2}\"",
                        group,
                        element,
                        tagValue.Value);
                    }
                    resultsReporter.WriteValidationInformation(message);
                }
            }

            _comparatorCollection.Compare(resultsReporter);

            if (_testAssertionResults.Count > 0)
            {
                resultsReporter.WriteHtmlInformation("<br/><br/><h2>Scenario Assertions</h2>");

                foreach (String testAssertionResult in _testAssertionResults)
                {
                    resultsReporter.WriteValidationError(testAssertionResult);
                }
            }

            // update the error and warnings counters
            resultsReporter.AddValidationErrors(this.NrErrors());
            resultsReporter.AddValidationWarnings(this.NrWarnings());
        }