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;
            }
        }
        //param childIndexName may have an integer on the end if >1 sibling with same name (e.g. NTE2)
        private void  parseReps(System.Xml.XmlElement groupElement, Group groupObject, System.String messageName, System.String childName, System.String childIndexName)
        {
            System.Collections.IList reps = getChildElementsByTagName(groupElement, makeGroupElementName(messageName, childName));

            if (groupObject.isRepeating(childIndexName))
            {
                for (int i = 0; i < reps.Count; i++)
                {
                    parseRep((System.Xml.XmlElement)reps[i], groupObject.get_Renamed(childIndexName, i));
                }
            }
            else
            {
                if (reps.Count > 0)
                {
                    parseRep((System.Xml.XmlElement)reps[0], groupObject.get_Renamed(childIndexName, 0));
                }

                if (reps.Count > 1)
                {
                    System.String newIndexName = groupObject.addNonstandardSegment(childName);
                    for (int i = 1; i < reps.Count; i++)
                    {
                        parseRep((System.Xml.XmlElement)reps[i], groupObject.get_Renamed(newIndexName, i - 1));
                    }
                }
            }
        }
		/// <summary> Creates new SegmentPointer </summary>
		/// <param name="parser">the PipeParser used to parse segments 
		/// </param>
		/// <param name="parent">the Group object that would be the parent of any instances of the 
		/// Segment underlying this SegmentPointer
		/// </param>
		/// <param name="position">the position (among siblings; from 0) of the underlying Segment 
		/// </param>
		/// <param name="encodingChars">array of encoding characters, starting w/ field delim
		/// </param>
		public NuGenSegmentPointer(NuGenPipeParser parser, Group parent, int position, NuGenEncodingCharacters encodingChars)
		{
			this.parser = parser;
			this.parent = parent;
			this.encodingChars = encodingChars;
			this.name = parent.Names[position];
			this.repeating = parent.isRepeating(this.name);
		}
Exemple #5
0
 /// <summary> Creates new SegmentPointer </summary>
 /// <param name="parser">the PipeParser used to parse segments
 /// </param>
 /// <param name="parent">the Group object that would be the parent of any instances of the
 /// Segment underlying this SegmentPointer
 /// </param>
 /// <param name="position">the position (among siblings; from 0) of the underlying Segment
 /// </param>
 /// <param name="encodingChars">array of encoding characters, starting w/ field delim
 /// </param>
 public NuGenSegmentPointer(NuGenPipeParser parser, Group parent, int position, NuGenEncodingCharacters encodingChars)
 {
     this.parser        = parser;
     this.parent        = parent;
     this.encodingChars = encodingChars;
     this.name          = parent.Names[position];
     this.repeating     = parent.isRepeating(this.name);
 }
		/// <summary> Creates new GroupPointer </summary>
		public NuGenGroupPointer(NuGenPipeParser parser, Group parent, int position, NuGenEncodingCharacters encodingChars)
		{
			this.parser = parser;
			this.parent = parent;
			this.name = parent.Names[position];
			this.repeating = parent.isRepeating(this.name);
			this.encodingChars = encodingChars;
			//this.createNewInstance();  
		}
 /// <summary> Creates new GroupPointer </summary>
 public NuGenGroupPointer(NuGenPipeParser parser, Group parent, int position, NuGenEncodingCharacters encodingChars)
 {
     this.parser        = parser;
     this.parent        = parent;
     this.name          = parent.Names[position];
     this.repeating     = parent.isRepeating(this.name);
     this.encodingChars = encodingChars;
     //this.createNewInstance();
 }
Exemple #8
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));
        }
Exemple #9
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.");
         }
     }
 }
		//param childIndexName may have an integer on the end if >1 sibling with same name (e.g. NTE2) 
		private void  parseReps(System.Xml.XmlElement groupElement, Group groupObject, System.String messageName, System.String childName, System.String childIndexName)
		{
			
			System.Collections.IList reps = getChildElementsByTagName(groupElement, makeGroupElementName(messageName, childName));
			
			if (groupObject.isRepeating(childIndexName))
			{
				for (int i = 0; i < reps.Count; i++)
				{
					parseRep((System.Xml.XmlElement) reps[i], groupObject.get_Renamed(childIndexName, i));
				}
			}
			else
			{
				if (reps.Count > 0)
				{
					parseRep((System.Xml.XmlElement) reps[0], groupObject.get_Renamed(childIndexName, 0));
				}
				
				if (reps.Count > 1)
				{
					System.String newIndexName = groupObject.addNonstandardSegment(childName);
					for (int i = 1; i < reps.Count; i++)
					{
						parseRep((System.Xml.XmlElement) reps[i], groupObject.get_Renamed(newIndexName, i - 1));
					}
				}
			}
		}
Exemple #11
0
        private System.Collections.IList myRemaining;         //remaining nodes in reverse order (i.e. last is next)

        /// <param name="theRoot">root of depth first iteration, which starts with the first child
        /// </param>
        public NuGenReadOnlyMessageIterator(Group theRoot)
        {
            myRemaining = new System.Collections.ArrayList(40);
            addChildren(theRoot);
        }
		/// <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.");
				}
			}
		}
		/// <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);
		}
		private System.Collections.IList myRemaining; //remaining nodes in reverse order (i.e. last is next)
		
		/// <param name="theRoot">root of depth first iteration, which starts with the first child  
		/// </param>
		public NuGenReadOnlyMessageIterator(Group theRoot)
		{
			myRemaining = new System.Collections.ArrayList(40);
			addChildren(theRoot);
		}
		/// <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;
			}
		}