Exemple #1
0
        /// <summary> Returns given group serialized as a pipe-encoded string - this method is called
        /// by encode(Message source, String encoding).
        /// </summary>
        public static System.String encode(Group source, NuGenEncodingCharacters encodingChars)
        {
            System.Text.StringBuilder result = new System.Text.StringBuilder();

            System.String[] names = source.Names;
            for (int i = 0; i < names.Length; i++)
            {
                Structure[] reps = source.getAll(names[i]);
                for (int rep = 0; rep < reps.Length; rep++)
                {
                    if (reps[rep] is Group)
                    {
                        result.Append(encode((Group)reps[rep], encodingChars));
                    }
                    else
                    {
                        System.String segString = encode((Segment)reps[rep], encodingChars);
                        if (segString.Length >= 4)
                        {
                            result.Append(segString);
                            result.Append('\r');
                        }
                    }
                }
            }
            return(result.ToString());
        }
        /// <summary> Creates a new, empty repetition of the underlying Group and sets up
        /// Pointers to it's components.
        /// </summary>
        /// <thows>  HL7Exception if there is already 1 rep and group is non-repeating </thows>
        private void  createNewInstance()
        {
            //find next rep # ...
            int nextRepNum = parent.getAll(this.name).Length;

            this.currentGroup        = (Group)parent.get_Renamed(this.name, nextRepNum);
            this.childAtWhichToStart = 0;

            //set up pointers for children ...
            System.String[] childNames = currentGroup.Names;
            this.children = new NuGenPointer[childNames.Length];
            for (int i = 0; i < childNames.Length; i++)
            {
                NuGenPointer p;
                //make new SegmentPointer or GroupPointer depending on whether child is a Group ...
                System.Type childClass = currentGroup.getClass(childNames[i]);
                if (typeof(Group).IsAssignableFrom(childClass))
                {
                    p = new NuGenGroupPointer(this.parser, currentGroup, i, this.encodingChars);
                }
                else
                {
                    p = new NuGenSegmentPointer(this.parser, currentGroup, i, encodingChars);
                }

                this.children[i] = p;
            }
        }
Exemple #3
0
        /// <summary> Ensures that there is an empty repetition of the underlying message Structure.  </summary>
        /// <returns>s true if successful, false if structure is non-repeating and full.
        /// </returns>
        private bool prepEmptyInstance()
        {
            bool success = false;

            if (this.currSegment == null || (this.repeating && this.currSegmentFull))
            {
                int numExisting = parent.getAll(this.name).Length;
                this.currSegment     = (Segment)parent.get_Renamed(this.name, numExisting);              //get next rep
                this.currSegmentFull = false;
                success = true;
            }
            else if (!this.currSegmentFull)
            {
                success = true;
            }

            return(success);
        }
Exemple #4
0
 private void  addChildren(Group theParent)
 {
     System.String[] names = theParent.Names;
     for (int i = names.Length - 1; i >= 0; i--)
     {
         try
         {
             Structure[] reps = theParent.getAll(names[i]);
             for (int j = reps.Length - 1; j >= 0; j--)
             {
                 myRemaining.Add(reps[j]);
             }
         }
         catch (NuGenHL7Exception)
         {
             throw new System.ApplicationException("Internal error: an invalid child name was obtained from its parent.");
         }
     }
 }
		/// <summary> Returns given group serialized as a pipe-encoded string - this method is called
		/// by encode(Message source, String encoding).
		/// </summary>
		public static System.String encode(Group source, NuGenEncodingCharacters encodingChars)
		{
			System.Text.StringBuilder result = new System.Text.StringBuilder();
			
			System.String[] names = source.Names;
			for (int i = 0; i < names.Length; i++)
			{
				Structure[] reps = source.getAll(names[i]);
				for (int rep = 0; rep < reps.Length; rep++)
				{
					if (reps[rep] is Group)
					{
						result.Append(encode((Group) reps[rep], encodingChars));
					}
					else
					{
						System.String segString = encode((Segment) reps[rep], encodingChars);
						if (segString.Length >= 4)
						{
							result.Append(segString);
							result.Append('\r');
						}
					}
				}
			}
			return result.ToString();
		}
		private void  addChildren(Group theParent)
		{
			System.String[] names = theParent.Names;
			for (int i = names.Length - 1; i >= 0; i--)
			{
				try
				{
					Structure[] reps = theParent.getAll(names[i]);
					for (int j = reps.Length - 1; j >= 0; j--)
					{
						myRemaining.Add(reps[j]);
					}
				}
				catch (NuGenHL7Exception)
				{
					throw new System.ApplicationException("Internal error: an invalid child name was obtained from its parent.");
				}
			}
		}