Ejemplo n.º 1
0
        private TagValueCollection GenerateTagValueCollection(TagValueCollection tagValueFilterCollection)
        {
            TagValueCollection localTagValueCollection = new TagValueCollection();

            // Check if the comparator can be used with a Universal Match on the Value of the Tag
            // - that is zero-length Value.
            if (this.UseComparator(tagValueFilterCollection, true) == true)
            {
                foreach(BaseTagValue baseTagValue in tagValueFilterCollection)
                {
                    Hl7TagValue hl7TagValue = null;

                    if (baseTagValue is Hl7TagValue)
                    {
                        hl7TagValue = (Hl7TagValue)baseTagValue;
                    }
                    else if (baseTagValue is DicomTagValue)
                    {
                        DicomTagValue dicomTagValue = (DicomTagValue)baseTagValue;
                        hl7TagValue = new Hl7TagValue(DicomHl7TagMapTemplate.DicomToHl7Tag(dicomTagValue.Tag), dicomTagValue.Value);
                    }

                    // If the Value is empty (Universal Match) then try to get the actual
                    // value from the comparator so that is actual value will be used against
                    // other comparators.
                    if (hl7TagValue.Tag != null)
                    {
                        if (hl7TagValue.Value == System.String.Empty)
                        {
                            // try to get a value for this Tag from this comparator
                            System.String lValue = getValue(hl7TagValue.Tag);

                            // Add a new Tag Value - with Value coming from this comparator
                            // to the local filter.
                            Hl7TagValue lHl7TagValue = new Hl7TagValue(hl7TagValue.Tag, lValue);
                            localTagValueCollection.Add(lHl7TagValue);
                        }
                        else
                        {
                            // Just add the given Tag Value pair to the local filter
                            localTagValueCollection.Add(hl7TagValue);
                        }
                    }
                }
            }

            // Return the local filter
            return localTagValueCollection;
        }
Ejemplo n.º 2
0
        public bool UseComparator(TagValueCollection tagValueFilterCollection, bool universalMatchAllowed)
        {
            int filterCounter = 0;

            // Check if the filter values match those in the template
            foreach(BaseTagValue baseTagValue in tagValueFilterCollection)
            {
                Hl7TagValue hl7TagValue = null;

                if (baseTagValue is Hl7TagValue)
                {
                    hl7TagValue = (Hl7TagValue)baseTagValue;
                }
                else if (baseTagValue is DicomTagValue)
                {
                    DicomTagValue dicomTagValue = (DicomTagValue)baseTagValue;
                    hl7TagValue = new Hl7TagValue(DicomHl7TagMapTemplate.DicomToHl7Tag(dicomTagValue.Tag), dicomTagValue.Value);
                }

                if (hl7TagValue.Tag != null)
                {
                    foreach (Hl7ComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // Tags are the same
                        if (thisComparisonTag.Tag == hl7TagValue.Tag)
                        {
                            if (universalMatchAllowed == true)
                            {
                                // When universal matching either a zero-length or exact match are OK
                                if ((hl7TagValue.Value == System.String.Empty) ||
                                    (thisComparisonTag.DataFormat.ToHl7Format() == hl7TagValue.Value))
                                {
                                    filterCounter++;
                                }
                            }
                            else if ((universalMatchAllowed == false) &&
                                (thisComparisonTag.DataFormat.ToHl7Format() == hl7TagValue.Value))
                            {
                                // Not universal matching so only an exact match is OK
                                filterCounter++;
                            }
                            break;
                        }
                    }
                }
            }

            bool useThisComparator = (tagValueFilterCollection.Count == filterCounter) ? true : false;

            return useThisComparator;
        }