Esempio n. 1
0
        public override void Parse(IMessage message, string @string, ParserOptions parserOptions)
        {
            if (parserOptions is null)
            {
                throw new ArgumentNullException(nameof(parserOptions));
            }

            var messageIter = new Util.MessageIterator(message, "MSH", true);

            FilterIterator.IPredicate segmentsOnly = new AnonymousClassPredicate(this);
            var segmentIter = new FilterIterator(messageIter, segmentsOnly);

            var segments      = Split(@string, SegDelim);
            var encodingChars = GetEncodingChars(@string);

            var delimiter = '|';

            for (var i = 0; i < segments.Length; i++)
            {
                // get rid of any leading whitespace characters ...
                if (segments[i] != null && segments[i].Length > 0 && char.IsWhiteSpace(segments[i][0]))
                {
                    segments[i] = StripLeadingWhitespace(segments[i]);
                }

                // sometimes people put extra segment delimiters at end of msg ...
                if (segments[i] != null && segments[i].Length >= 3)
                {
                    var name = segments[i].Substring(0, 3 - 0);
                    if (i == 0)
                    {
                        name      = segments[i].Substring(0, 3);
                        delimiter = segments[i][3];
                    }
                    else
                    {
                        name = segments[i].IndexOf(delimiter) >= 0
                            ? segments[i].Substring(0, segments[i].IndexOf(delimiter))
                            : segments[i];
                    }

                    Log.Debug("Parsing segment " + name);

                    messageIter.Direction = name;
                    FilterIterator.IPredicate byDirection = new AnonymousClassPredicate1(name, this);
                    var dirIter = new FilterIterator(segmentIter, byDirection);

                    if (dirIter.MoveNext())
                    {
                        Parse((ISegment)dirIter.Current, segments[i], encodingChars, parserOptions);
                    }
                }
            }
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        /// <summary> Parses a message string and returns the corresponding Message
        /// object.  Unexpected segments added at the end of their group.
        ///
        /// </summary>
        /// <throws>  HL7Exception if the message is not correctly formatted. </throws>
        /// <throws>  EncodingNotSupportedException if the message encoded </throws>
        /// <summary>      is not supported by this parser.
        /// </summary>
        protected internal override Message doParse(System.String message, System.String version)
        {
            //try to instantiate a message object of the right class
            MessageStructure structure = getStructure(message);
            Message          m         = instantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

            //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
            MessageIterator messageIter = new MessageIterator(m, "MSH", true);

            FilterIterator.Predicate segmentsOnly = new AnonymousClassPredicate(this);
            FilterIterator           segmentIter  = new FilterIterator(messageIter, segmentsOnly);

            System.String[] segments = split(message, segDelim);

            char delim = '|';

            for (int i = 0; i < segments.Length; i++)
            {
                //get rid of any leading whitespace characters ...
                if (segments[i] != null && segments[i].Length > 0 && System.Char.IsWhiteSpace(segments[i][0]))
                {
                    segments[i] = stripLeadingWhitespace(segments[i]);
                }

                //sometimes people put extra segment delimiters at end of msg ...
                if (segments[i] != null && segments[i].Length >= 3)
                {
                    System.String name;
                    if (i == 0)
                    {
                        name  = segments[i].Substring(0, (3) - (0));
                        delim = segments[i][3];
                    }
                    else
                    {
                        name = segments[i].Substring(0, (segments[i].IndexOf((System.Char)delim)) - (0));
                    }


                    messageIter.Direction = name;
                    FilterIterator.Predicate byDirection = new AnonymousClassPredicate1(name, this);
                    FilterIterator           dirIter     = new FilterIterator(segmentIter, byDirection);
                    if (dirIter.MoveNext())
                    {
                        parse((Segment)dirIter.Current, segments[i], getEncodingChars(message));
                    }
                }
            }
            return(m);
        }
Esempio n. 4
0
        /// <summary> Parses a message string and returns the corresponding Message
        /// object.  Unexpected segments added at the end of their group.
        ///
        /// </summary>
        /// <throws>  HL7Exception if the message is not correctly formatted. </throws>
        /// <throws>  EncodingNotSupportedException if the message encoded </throws>
        /// <summary>      is not supported by this parser.
        /// </summary>
        protected internal override Message doParse(System.String message, System.String version)
        {
            //try to instantiate a message object of the right class
            MessageStructure structure = getStructure(message);
            Message          m         = instantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

            //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
            MessageIterator messageIter = new MessageIterator(m, "MSH", true);

            FilterIterator.Predicate segmentsOnly = new AnonymousClassPredicate(this);
            FilterIterator           segmentIter  = new FilterIterator(messageIter, segmentsOnly);

            System.String[] segments = split(message, segDelim);
            for (int i = 0; i < segments.Length; i++)
            {
                //get rid of any leading whitespace characters ...
                if (segments[i] != null && segments[i].Length > 0 && System.Char.IsWhiteSpace(segments[i][0]))
                {
                    segments[i] = stripLeadingWhitespace(segments[i]);
                }

                //sometimes people put extra segment delimiters at end of msg ...
                if (segments[i] != null && segments[i].Length >= 3)
                {
                    //UPGRADE_NOTE: Final was removed from the declaration of 'name '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                    System.String name = segments[i].Substring(0, (3) - (0));
                    log.debug("Parsing segment " + name);

                    messageIter.Direction = name;
                    FilterIterator.Predicate byDirection = new AnonymousClassPredicate1(name, this);
                    FilterIterator           dirIter     = new FilterIterator(segmentIter, byDirection);
                    //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                    if (dirIter.MoveNext())
                    {
                        //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                        parse((Segment)dirIter.Current, segments[i], getEncodingChars(message));
                    }
                }
            }
            return(m);
        }
Esempio n. 5
0
        /// <summary> Parses a message string and returns the corresponding Message
        /// object.  Unexpected segments added at the end of their group.
        ///
        /// </summary>
        /// <throws>  HL7Exception if the message is not correctly formatted. </throws>
        /// <throws>  EncodingNotSupportedException if the message encoded </throws>
        /// <summary>      is not supported by this parser.
        /// </summary>
        protected internal override IMessage DoParse(String message, String version)
        {
            //try to instantiate a message object of the right class
            MessageStructure structure = GetStructure(message);
            IMessage         m         = InstantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

            //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
            MessageIterator messageIter = new MessageIterator(m, "MSH", true);

            FilterIterator.IPredicate segmentsOnly = new AnonymousClassPredicate(this);
            FilterIterator            segmentIter  = new FilterIterator(messageIter, segmentsOnly);

            String[]           segments      = Split(message, segDelim);
            EncodingCharacters encodingChars = GetEncodingChars(message);

            for (int i = 0; i < segments.Length; i++)
            {
                //get rid of any leading whitespace characters ...
                if (segments[i] != null && segments[i].Length > 0 && Char.IsWhiteSpace(segments[i][0]))
                {
                    segments[i] = StripLeadingWhitespace(segments[i]);
                }

                //sometimes people put extra segment delimiters at end of msg ...
                if (segments[i] != null && segments[i].Length >= 3)
                {
                    String name = segments[i].Substring(0, (3) - (0));
                    log.Debug("Parsing segment " + name);

                    messageIter.Direction = name;
                    FilterIterator.IPredicate byDirection = new AnonymousClassPredicate1(name, this);
                    FilterIterator            dirIter     = new FilterIterator(segmentIter, byDirection);
                    if (dirIter.MoveNext())
                    {
                        Parse((ISegment)dirIter.Current, segments[i], encodingChars);
                    }
                }
            }
            return(m);
        }
Esempio n. 6
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)
        {
            IStructure start = null;

            if (currentChild == -1)
            {
                start = CurrentGroup;
            }
            else
            {
                start = CurrentGroup.GetStructure(childNames[currentChild]);
            }

            // using a non-existent direction and not allowing segment creation means that only
            // the first rep of anything is traversed.
            IEnumerator it = new MessageIterator(start, "doesn't exist", false);

            if (segmentsOnly)
            {
                FilterIterator.IPredicate predicate = new AnonymousClassPredicate(this);
                it = new FilterIterator(it, predicate);
            }

            if (it.MoveNext())
            {
                var next = (IStructure)it.Current;
                DrillHere(next);
            }
            else if (loop)
            {
                Reset();
            }
            else
            {
                throw new HL7Exception(
                          "End of message reached while iterating without loop",
                          ErrorCode.APPLICATION_INTERNAL_ERROR);
            }
        }
Esempio n. 7
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 MessageIterator(start, "doesn't exist", false);
            if (segmentsOnly)
            {
                FilterIterator.Predicate predicate = new AnonymousClassPredicate(this);
                it = new FilterIterator(it, predicate);
            }

            //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
            if (it.MoveNext())
            {
                //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                Structure next = (Structure)it.Current;
                drillHere(next);
            }
            else if (loop)
            {
                this.reset();
            }
            else
            {
                throw new HL7Exception("End of message reached while iterating without loop", HL7Exception.APPLICATION_INTERNAL_ERROR);
            }
        }
Esempio n. 8
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);
            }
        }
		/// <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);
			}
		}
Esempio n. 10
0
		/// <summary> Parses a message string and returns the corresponding Message
		/// object.  Unexpected segments added at the end of their group.  
		/// 
		/// </summary>
		/// <throws>  HL7Exception if the message is not correctly formatted. </throws>
		/// <throws>  EncodingNotSupportedException if the message encoded </throws>
		/// <summary>      is not supported by this parser.
		/// </summary>
		protected internal override IMessage DoParse(String message, String version)
		{
			//try to instantiate a message object of the right class
			MessageStructure structure = GetStructure(message);
			IMessage m = InstantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

			//MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
			MessageIterator messageIter = new MessageIterator(m, "MSH", true);
			FilterIterator.IPredicate segmentsOnly = new AnonymousClassPredicate(this);
			FilterIterator segmentIter = new FilterIterator(messageIter, segmentsOnly);

			String[] segments = Split(message, segDelim);
			EncodingCharacters encodingChars = GetEncodingChars(message);
			for (int i = 0; i < segments.Length; i++)
			{
				//get rid of any leading whitespace characters ...
				if (segments[i] != null && segments[i].Length > 0 && Char.IsWhiteSpace(segments[i][0]))
					segments[i] = StripLeadingWhitespace(segments[i]);

				//sometimes people put extra segment delimiters at end of msg ...
				if (segments[i] != null && segments[i].Length >= 3)
				{
					String name = segments[i].Substring(0, (3) - (0));
					log.Debug("Parsing segment " + name);

					messageIter.Direction = name;
					FilterIterator.IPredicate byDirection = new AnonymousClassPredicate1(name, this);
					FilterIterator dirIter = new FilterIterator(segmentIter, byDirection);
					if (dirIter.MoveNext())
					{
						Parse((ISegment) dirIter.Current, segments[i], encodingChars);
					}
				}
			}
			return m;
		}
Esempio n. 11
0
		/// <summary> Parses a message string and returns the corresponding Message
		/// object.  Unexpected segments added at the end of their group.  
		/// 
		/// </summary>
		/// <throws>  HL7Exception if the message is not correctly formatted. </throws>
		/// <throws>  EncodingNotSupportedException if the message encoded </throws>
		/// <summary>      is not supported by this parser.
		/// </summary>
		protected internal override Message doParse(System.String message, System.String version)
		{
			
			//try to instantiate a message object of the right class
			MessageStructure structure = getStructure(message);
			Message m = instantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);
			
			//MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
			MessageIterator messageIter = new MessageIterator(m, "MSH", true);
			FilterIterator.Predicate segmentsOnly = new AnonymousClassPredicate(this);
			FilterIterator segmentIter = new FilterIterator(messageIter, segmentsOnly);
			
			System.String[] segments = split(message, segDelim);
			
			char delim = '|';
			for (int i = 0; i < segments.Length; i++)
			{
				
				//get rid of any leading whitespace characters ...
				if (segments[i] != null && segments[i].Length > 0 && System.Char.IsWhiteSpace(segments[i][0]))
					segments[i] = stripLeadingWhitespace(segments[i]);
				
				//sometimes people put extra segment delimiters at end of msg ...
				if (segments[i] != null && segments[i].Length >= 3)
				{
					System.String name;
					if (i == 0)
					{
						name = segments[i].Substring(0, (3) - (0));
						delim = segments[i][3];
					}
					else
					{
						name = segments[i].Substring(0, (segments[i].IndexOf((System.Char) delim)) - (0));
					}
					
					
					messageIter.Direction = name;
					FilterIterator.Predicate byDirection = new AnonymousClassPredicate1(name, this);
					FilterIterator dirIter = new FilterIterator(segmentIter, byDirection);
					if (dirIter.MoveNext())
					{
						parse((Segment) dirIter.Current, segments[i], getEncodingChars(message));
					}
				}
			}
			return m;
		}
Esempio n. 12
0
        /// <summary> Parses a message string and returns the corresponding Message
        /// object.  Unexpected segments added at the end of their group.  
        /// 
        /// </summary>
        /// <throws>  HL7Exception if the message is not correctly formatted. </throws>
        /// <throws>  EncodingNotSupportedException if the message encoded </throws>
        /// <summary>      is not supported by this parser.
        /// </summary>
        protected internal override Message doParse(System.String message, System.String version)
        {
            //try to instantiate a message object of the right class
            MessageStructure structure = getStructure(message);
            Message m = instantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

            //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
            MessageIterator messageIter = new MessageIterator(m, "MSH", true);
            FilterIterator.Predicate segmentsOnly = new AnonymousClassPredicate(this);
            FilterIterator segmentIter = new FilterIterator(messageIter, segmentsOnly);

            System.String[] segments = split(message, segDelim);
            for (int i = 0; i < segments.Length; i++)
            {

                //get rid of any leading whitespace characters ...
                if (segments[i] != null && segments[i].Length > 0 && System.Char.IsWhiteSpace(segments[i][0]))
                    segments[i] = stripLeadingWhitespace(segments[i]);

                //sometimes people put extra segment delimiters at end of msg ...
                if (segments[i] != null && segments[i].Length >= 3)
                {
                    //UPGRADE_NOTE: Final was removed from the declaration of 'name '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                    System.String name = segments[i].Substring(0, (3) - (0));
                    log.debug("Parsing segment " + name);

                    messageIter.Direction = name;
                    FilterIterator.Predicate byDirection = new AnonymousClassPredicate1(name, this);
                    FilterIterator dirIter = new FilterIterator(segmentIter, byDirection);
                    //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                    if (dirIter.MoveNext())
                    {
                        //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                        parse((Segment) dirIter.Current, segments[i], getEncodingChars(message));
                    }
                }
            }
            return m;
        }
Esempio n. 13
0
        /// <summary> Parses a message string and returns the corresponding Message
        /// object.  Unexpected segments added at the end of their group.  
        /// 
        /// </summary>
        /// <throws>  HL7Exception if the message is not correctly formatted. </throws>
        /// <throws>  EncodingNotSupportedException if the message encoded </throws>
        /// <summary>      is not supported by this parser.
        /// </summary>
        protected internal override IMessage DoParse(String message, String version)
        {
            //try to instantiate a message object of the right class
            MessageStructure structure = GetStructure(message);
            IMessage m = InstantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

            //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
            MessageIterator messageIter = new MessageIterator(m, "MSH", true);
            FilterIterator.IPredicate segmentsOnly = new AnonymousClassPredicate(this);
            FilterIterator segmentIter = new FilterIterator(messageIter, segmentsOnly);

            string lastSegmentName = null;
            String[] segments = Split(message, segDelim);
            EncodingCharacters encodingChars = GetEncodingChars(message);
            for (int i = 0; i < segments.Length; i++)
            {
                //get rid of any leading whitespace characters ...
                if (segments[i] != null && segments[i].Length > 0 && Char.IsWhiteSpace(segments[i][0]))
                    segments[i] = StripLeadingWhitespace(segments[i]);

                //sometimes people put extra segment delimiters at end of msg ...
                if (segments[i] != null && segments[i].Length >= 3)
                {
                    String name = segments[i].Substring(0, (3) - (0));
                    log.Debug("Parsing segment " + name);
                    if (!name.Equals(lastSegmentName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        // If the message iterator passes a segment that is later encountered the message object won't be properly parsed.
                        // Rebuild the iterator for each segment, or fix iterator logic in handling unexpected segments.
                        messageIter = new MessageIterator(m, "MSH", true);
                        segmentsOnly = new AnonymousClassPredicate(this);
                        segmentIter = new FilterIterator(messageIter, segmentsOnly);
                        lastSegmentName = name;
                    }

                    messageIter.Direction = name;
                    FilterIterator.IPredicate byDirection = new AnonymousClassPredicate1(name, this);
                    FilterIterator dirIter = new FilterIterator(segmentIter, byDirection);
                    if (dirIter.MoveNext())
                    {
                        Parse((ISegment) dirIter.Current, segments[i], encodingChars);
                    }
                }
            }
            return m;
        }
Esempio n. 14
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 MessageIterator(start, "doesn't exist", false);
            if (segmentsOnly)
            {
                FilterIterator.Predicate predicate = new AnonymousClassPredicate(this);
                it = new FilterIterator(it, predicate);
            }

            //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
            if (it.MoveNext())
            {
                //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                Structure next = (Structure) it.Current;
                drillHere(next);
            }
            else if (loop)
            {
                this.reset();
            }
            else
            {
                throw new HL7Exception("End of message reached while iterating without loop", HL7Exception.APPLICATION_INTERNAL_ERROR);
            }
        }