예제 #1
0
        /// <param name="theRoot">root of depth first iteration, which starts with the first child
        /// </param>
        /// <returns> an iterator that skips groups and empty segments, returning only populated
        /// segments
        /// </returns>
        public static System.Collections.IEnumerator createPopulatedSegmentIterator(Group theRoot)
        {
            System.Collections.IEnumerator allIterator = new NuGenReadOnlyMessageIterator(theRoot);

            NuGenFilterIterator.Predicate segmentsOnly    = new AnonymousClassPredicate();
            NuGenFilterIterator           segmentIterator = new NuGenFilterIterator(allIterator, segmentsOnly);

            EncodingCharacters ec = new EncodingCharacters('|', "^~\\&");

            NuGenFilterIterator.Predicate populatedOnly = new AnonymousClassPredicate1(ec);
            return(new NuGenFilterIterator(segmentIterator, populatedOnly));
        }
예제 #2
0
        /// <summary> Iterates through the message tree to the next segment/group location (regardless
        /// of whether an instance of the segment exists).  If the end of the tree is
        /// reached, starts over at the root.  Only enters the first repetition of a
        /// repeating group -- explicit navigation (using the drill...() methods) is
        /// necessary to get to subsequent reps.
        /// </summary>
        /// <param name="segmentsOnly">if true, only stops at segments (not groups)
        /// </param>
        /// <param name="loop">if true, loops back to beginning when end of msg reached; if false,
        /// throws HL7Exception if end of msg reached
        /// </param>
        public virtual void  iterate(bool segmentsOnly, bool loop)
        {
            Structure start = null;

            if (this.currentChild == -1)
            {
                start = this.currentGroup;
            }
            else
            {
                start = (this.currentGroup.get_Renamed(this.childNames[this.currentChild]));
            }

            //using a non-existent direction and not allowing segment creation means that only
            //the first rep of anything is traversed.
            System.Collections.IEnumerator it = new NuGenMessageIterator(start, "doesn't exist", false);
            if (segmentsOnly)
            {
                NuGenFilterIterator.Predicate predicate = new AnonymousClassPredicate(this);
                it = new NuGenFilterIterator(it, predicate);
            }

            if (it.MoveNext())
            {
                Structure next = (Structure)it.Current;
                drillHere(next);
            }
            else if (loop)
            {
                this.reset();
            }
            else
            {
                throw new NuGenHL7Exception("End of message reached while iterating without loop", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR);
            }
        }
		public NuGenFilterIterator(System.Collections.IEnumerator iter, NuGenFilterIterator.Predicate predicate)
		{
			this.iter = iter;
			this.predicate = predicate;
		}
		/// <summary> Iterates through the message tree to the next segment/group location (regardless
		/// of whether an instance of the segment exists).  If the end of the tree is
		/// reached, starts over at the root.  Only enters the first repetition of a
		/// repeating group -- explicit navigation (using the drill...() methods) is
		/// necessary to get to subsequent reps.
		/// </summary>
		/// <param name="segmentsOnly">if true, only stops at segments (not groups)
		/// </param>
		/// <param name="loop">if true, loops back to beginning when end of msg reached; if false,
		/// throws HL7Exception if end of msg reached
		/// </param>
		public virtual void  iterate(bool segmentsOnly, bool loop)
		{
			Structure start = null;
			
			if (this.currentChild == - 1)
			{
				start = this.currentGroup;
			}
			else
			{
				start = (this.currentGroup.get_Renamed(this.childNames[this.currentChild]));
			}
			
			//using a non-existent direction and not allowing segment creation means that only
			//the first rep of anything is traversed.
			System.Collections.IEnumerator it = new NuGenMessageIterator(start, "doesn't exist", false);
			if (segmentsOnly)
			{
				NuGenFilterIterator.Predicate predicate = new AnonymousClassPredicate(this);
				it = new NuGenFilterIterator(it, predicate);
			}
			
			if (it.MoveNext())
			{
				Structure next = (Structure) it.Current;
				drillHere(next);
			}
			else if (loop)
			{
				this.reset();
			}
			else
			{
				throw new NuGenHL7Exception("End of message reached while iterating without loop", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR);
			}
		}
		/// <param name="theRoot">root of depth first iteration, which starts with the first child
		/// </param>
		/// <returns> an iterator that skips groups and empty segments, returning only populated 
		/// segments  
		/// </returns>
		public static System.Collections.IEnumerator createPopulatedSegmentIterator(Group theRoot)
		{
			System.Collections.IEnumerator allIterator = new NuGenReadOnlyMessageIterator(theRoot);
			
			NuGenFilterIterator.Predicate segmentsOnly = new AnonymousClassPredicate();
			NuGenFilterIterator segmentIterator = new NuGenFilterIterator(allIterator, segmentsOnly);
			
			EncodingCharacters ec = new EncodingCharacters('|', "^~\\&");
			NuGenFilterIterator.Predicate populatedOnly = new AnonymousClassPredicate1(ec);
			return new NuGenFilterIterator(segmentIterator, populatedOnly);
		}