/// <summary> Creates new GroupPointer </summary>
 public NuGenMessagePointer(NuGenPipeParser parser, Message message, NuGenEncodingCharacters encodingChars)
 {
     this.parser        = parser;
     this.message       = message;
     this.encodingChars = encodingChars;
     makeChildren();
 }
		/// <summary> Creates new GroupPointer </summary>
		public NuGenMessagePointer(NuGenPipeParser parser, Message message, NuGenEncodingCharacters encodingChars)
		{
			this.parser = parser;
			this.message = message;
			this.encodingChars = encodingChars;
			makeChildren();
		}
示例#3
0
            public Message processMessage(Message msg)
            {
                string encodedMessage = new NuGenPipeParser().encode(msg);

                MSH msh = (MSH)msg.get_Renamed("MSH");

                return NuGenDefaultApplication.makeACK(msh);
            }
示例#4
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 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();  
		}
示例#7
0
 /// <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();
 }
示例#8
0
        static void TestNetworkOperations()
        {
            NuGenLowerLayerProtocol llp = NuGenLowerLayerProtocol.makeLLP();
            NuGenPipeParser parser = new NuGenPipeParser();
            NuGenSimpleServer server = new NuGenSimpleServer(1011, llp, parser);

            NuGenApplication handler = new ExampleReceiverApplication();
            server.registerApplication("ADT", "A01", handler);
            server.registerApplication("ADT", "A02", handler);

            server.start();

            String msg = "MSH|^~\\&|HIS|RIH|EKG|EKG|199904140038||ADT^A01|12345|P|2.2\r"
                 //+ "EVN|A01|198808181123||\r"
                 + "PID|0001|00009874|00001122|A00977|SMITH^JOHN^M|MOM|19581119|F|NOTREAL^LINDA^M|C|564 SPRING ST^^NEEDHAM^MA^02494^US|0002|(818)565-1551|(425)828-3344|E|S|C|0000444444|252-00-4414||||SA|||SA||||NONE|V1|0001|I|D.ER^50A^M110^01|ER|P00055|11B^M011^02|070615^BATMAN^GEORGE^L|555888^NOTREAL^BOB^K^DR^MD|777889^NOTREAL^SAM^T^DR^MD^PHD|ER|D.WT^1A^M010^01|||ER|AMB|02|070615^NOTREAL^BILL^L|ER|000001916994|D||||||||||||||||GDD|WA|NORM|02|O|02|E.IN^02D^M090^01|E.IN^01D^M080^01|199904072124|199904101200|199904101200||||5555112333|||666097^NOTREAL^MANNY^P\r"
                 + "NK1|0222555|NOTREAL^JAMES^R|FA|STREET^OTHER STREET^CITY^ST^55566|(222)111-3333|(888)999-0000|||||||ORGANIZATION\r"
                 + "PV1|0001|I|D.ER^1F^M950^01|ER|P000998|11B^M011^02|070615^BATMAN^GEORGE^L|555888^OKNEL^BOB^K^DR^MD|777889^NOTREAL^SAM^T^DR^MD^PHD|ER|D.WT^1A^M010^01|||ER|AMB|02|070615^VOICE^BILL^L|ER|000001916994|D||||||||||||||||GDD|WA|NORM|02|O|02|E.IN^02D^M090^01|E.IN^01D^M080^01|199904072124|199904101200|||||5555112333|||666097^DNOTREAL^MANNY^P\r"
                 + "PV2|||0112^TESTING|55555^PATIENT IS NORMAL|NONE|||19990225|19990226|1|1|TESTING|555888^NOTREAL^BOB^K^DR^MD||||||||||PROD^003^099|02|ER||NONE|19990225|19990223|19990316|NONE\r"
                 + "AL1||SEV|001^POLLEN\r"
                 + "GT1||0222PL|NOTREAL^BOB^B||STREET^OTHER STREET^CITY^ST^77787|(444)999-3333|(222)777-5555||||MO|111-33-5555||||NOTREAL GILL N|STREET^OTHER STREET^CITY^ST^99999|(111)222-3333\r"
                 + "IN1||022254P|4558PD|BLUE CROSS|STREET^OTHER STREET^CITY^ST^00990||(333)333-6666||221K|LENIX|||19980515|19990515|||PATIENT01 TEST D||||||||||||||||||02LL|022LP554";
         
            NuGenParser p = new NuGenGenericParser();
            Message adt = p.parse(msg);

            NuGenConnectionHub hub = NuGenConnectionHub.Instance;

            NuGenConnection connection = hub.attach(System.Net.Dns.GetHostName(), 1011, new NuGenPipeParser(), new NuGenMinLowerLayerProtocol().GetType());

            NuGenInitiator init = connection.Initiator;

            Message response = init.sendAndReceive(adt);

            string responseStr = parser.encode(response);

            System.Console.WriteLine("Receieved response : " + responseStr);

            connection.close();

            server.stop();
        }
示例#9
0
 private void  InitBlock(System.String name, NuGenPipeParser enclosingInstance)
 {
     this.name = name;
     this.enclosingInstance = enclosingInstance;
 }
示例#10
0
 public AnonymousClassPredicate1(System.String name, NuGenPipeParser enclosingInstance)
 {
     InitBlock(name, enclosingInstance);
 }
示例#11
0
			public AnonymousClassPredicate1(System.String name, NuGenPipeParser enclosingInstance)
			{
				InitBlock(name, enclosingInstance);
			}
示例#12
0
		/// <param name="theEventGuideMap">a map with keys in the form "type^event" (like MSH-9 
		/// components 1 and 2).  Values are corresponding parsing guides for those events.  
		/// A parsing guide is a group of StructRef that identify which segments to parse, 
		/// the relationships between them, and where to find them in a message hierarchy.
		/// The value in the map is the RootRef of the message root.  It must return the 
		/// StructRef for the MSH segment from getSuccessor("MSH").  References to other 
		/// segments can be included as needed.   
		/// </param>
		public NuGenFastParser(System.Collections.IDictionary theEventGuideMap)
		{
			myEventGuideMap = theEventGuideMap;
			myPipeParser = new NuGenPipeParser();
		}
示例#13
0
 /// <summary>Creates a new instance of GenericParser </summary>
 public NuGenGenericParser() : base()
 {
     pipeParser = new NuGenPipeParser();
     xmlParser  = new NuGenDefaultXMLParser();
     setPipeParserAsPrimary();
 }
示例#14
0
        public static void  Main(System.String[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Out.WriteLine("Usage: XMLParser pipe_encoded_file");
                System.Environment.Exit(1);
            }

            //read and parse message from file
            try
            {
                NuGenPipeParser    parser      = new NuGenPipeParser();
                System.IO.FileInfo messageFile = new System.IO.FileInfo(args[0]);
                long fileLength          = SupportClass.FileLength(messageFile);
                System.IO.StreamReader r = new System.IO.StreamReader(messageFile.FullName, System.Text.Encoding.Default);
                char[] cbuf = new char[(int)fileLength];
                System.Console.Out.WriteLine("Reading message file ... " + r.Read((System.Char[])cbuf, 0, cbuf.Length) + " of " + fileLength + " chars");
                r.Close();
                System.String messString = System.Convert.ToString(cbuf);
                Message       mess       = parser.parse(messString);
                System.Console.Out.WriteLine("Got message of type " + mess.GetType().FullName);

                Genetibase.NuGenHL7.parser.NuGenXMLParser xp = new AnonymousClassXMLParser();

                //loop through segment children of message, encode, print to console
                System.String[] structNames = mess.Names;
                for (int i = 0; i < structNames.Length; i++)
                {
                    Structure[] reps = mess.getAll(structNames[i]);
                    for (int j = 0; j < reps.Length; j++)
                    {
                        if (typeof(Segment).IsAssignableFrom(reps[j].GetType()))
                        {
                            //ignore groups
                            System.Xml.XmlDocument docBuilder = new System.Xml.XmlDocument();
                            System.Xml.XmlDocument doc        = new System.Xml.XmlDocument();                      //new doc for each segment
                            System.Xml.XmlElement  root       = doc.CreateElement(reps[j].GetType().FullName);
                            doc.AppendChild(root);
                            xp.encode((Segment)reps[j], root);
                            System.IO.StringWriter out_Renamed = new System.IO.StringWriter();
                            System.Console.Out.WriteLine("Segment " + reps[j].GetType().FullName + ": \r\n" + out_Renamed.ToString());

                            System.Type[]   segmentConstructTypes = new System.Type[] { typeof(Message) };
                            System.Object[] segmentConstructArgs  = new System.Object[] { null };
                            Segment         s = (Segment)reps[j].GetType().GetConstructor(segmentConstructTypes).Invoke(segmentConstructArgs);
                            xp.parse(s, root);
                            System.Xml.XmlDocument doc2  = new System.Xml.XmlDocument();
                            System.Xml.XmlElement  root2 = doc2.CreateElement(s.GetType().FullName);
                            doc2.AppendChild(root2);
                            xp.encode(s, root2);
                            System.IO.StringWriter out2 = new System.IO.StringWriter();

                            if (out2.ToString().Equals(out_Renamed.ToString()))
                            {
                                System.Console.Out.WriteLine("Re-encode OK");
                            }
                            else
                            {
                                System.Console.Out.WriteLine("Warning: XML different after parse and re-encode: \r\n" + out2.ToString());
                            }
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
示例#15
0
			public AnonymousClassPredicate(NuGenPipeParser enclosingInstance)
			{
				InitBlock(enclosingInstance);
			}
示例#16
0
			private void  InitBlock(NuGenPipeParser enclosingInstance)
			{
				this.enclosingInstance = enclosingInstance;
			}
示例#17
0
 public AnonymousClassPredicate(NuGenPipeParser enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
示例#18
0
			private void  InitBlock(System.String name, NuGenPipeParser enclosingInstance)
			{
				this.name = name;
				this.enclosingInstance = enclosingInstance;
			}
示例#19
0
 private void  InitBlock(NuGenPipeParser enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
示例#20
0
 /// <param name="theEventGuideMap">a map with keys in the form "type^event" (like MSH-9
 /// components 1 and 2).  Values are corresponding parsing guides for those events.
 /// A parsing guide is a group of StructRef that identify which segments to parse,
 /// the relationships between them, and where to find them in a message hierarchy.
 /// The value in the map is the RootRef of the message root.  It must return the
 /// StructRef for the MSH segment from getSuccessor("MSH").  References to other
 /// segments can be included as needed.
 /// </param>
 public NuGenFastParser(System.Collections.IDictionary theEventGuideMap)
 {
     myEventGuideMap = theEventGuideMap;
     myPipeParser    = new NuGenPipeParser();
 }
示例#21
0
		public static void  Main(System.String[] args)
		{
			if (args.Length != 1)
			{
				System.Console.Out.WriteLine("Usage: XMLParser pipe_encoded_file");
				System.Environment.Exit(1);
			}
			
			//read and parse message from file 
			try
			{
				NuGenPipeParser parser = new NuGenPipeParser();
				System.IO.FileInfo messageFile = new System.IO.FileInfo(args[0]);
				long fileLength = SupportClass.FileLength(messageFile);
				System.IO.StreamReader r = new System.IO.StreamReader(messageFile.FullName, System.Text.Encoding.Default);
				char[] cbuf = new char[(int) fileLength];
				System.Console.Out.WriteLine("Reading message file ... " + r.Read((System.Char[]) cbuf, 0, cbuf.Length) + " of " + fileLength + " chars");
				r.Close();
				System.String messString = System.Convert.ToString(cbuf);
				Message mess = parser.parse(messString);
				System.Console.Out.WriteLine("Got message of type " + mess.GetType().FullName);
				
				Genetibase.NuGenHL7.parser.NuGenXMLParser xp = new AnonymousClassXMLParser();
				
				//loop through segment children of message, encode, print to console
				System.String[] structNames = mess.Names;
				for (int i = 0; i < structNames.Length; i++)
				{
					Structure[] reps = mess.getAll(structNames[i]);
					for (int j = 0; j < reps.Length; j++)
					{
						if (typeof(Segment).IsAssignableFrom(reps[j].GetType()))
						{
							//ignore groups
							System.Xml.XmlDocument docBuilder = new System.Xml.XmlDocument();
							System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //new doc for each segment
							System.Xml.XmlElement root = doc.CreateElement(reps[j].GetType().FullName);
							doc.AppendChild(root);
							xp.encode((Segment) reps[j], root);
							System.IO.StringWriter out_Renamed = new System.IO.StringWriter();
							System.Console.Out.WriteLine("Segment " + reps[j].GetType().FullName + ": \r\n" + out_Renamed.ToString());
							
							System.Type[] segmentConstructTypes = new System.Type[]{typeof(Message)};
							System.Object[] segmentConstructArgs = new System.Object[]{null};
							Segment s = (Segment) reps[j].GetType().GetConstructor(segmentConstructTypes).Invoke(segmentConstructArgs);
							xp.parse(s, root);
							System.Xml.XmlDocument doc2 = new System.Xml.XmlDocument();
							System.Xml.XmlElement root2 = doc2.CreateElement(s.GetType().FullName);
							doc2.AppendChild(root2);
							xp.encode(s, root2);
							System.IO.StringWriter out2 = new System.IO.StringWriter();

							if (out2.ToString().Equals(out_Renamed.ToString()))
							{
								System.Console.Out.WriteLine("Re-encode OK");
							}
							else
							{
								System.Console.Out.WriteLine("Warning: XML different after parse and re-encode: \r\n" + out2.ToString());
							}
						}
					}
				}
			}
			catch (System.Exception e)
			{
				SupportClass.WriteStackTrace(e, Console.Error);
			}
		}