Пример #1
0
        /// <summary>Tests for extra components (ie any not defined in the profile) </summary>
        private NuGenHL7Exception[] checkExtraComponents(Composite comp, int numInProfile)
        {
            System.Collections.ArrayList exList = new System.Collections.ArrayList(20);

            System.Text.StringBuilder extra = new System.Text.StringBuilder();
            for (int i = numInProfile; i < comp.Components.Length; i++)
            {
                try
                {
                    System.String s = NuGenPipeParser.encode(comp.getComponent(i), enc);
                    if (s.Length > 0)
                    {
                        extra.Append(s);
                        extra.Append(enc.ComponentSeparator);
                    }
                }
                catch (DataTypeException de)
                {
                    throw new NuGenProfileException("Problem testing against profile", de);
                }
            }

            if (extra.ToString().Length > 0)
            {
                exList.Add(new NuGenXElementPresentException("The following components are not defined in the profile: " + extra.ToString()));
            }

            return(toArray(exList));
        }
Пример #2
0
            public Message processMessage(Message msg)
            {
                string encodedMessage = new NuGenPipeParser().encode(msg);

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

                return(NuGenDefaultApplication.makeACK(msh));
            }
Пример #3
0
        /// <summary>Returns true is there is content in the given type </summary>
        private bool hasContent(Genetibase.NuGenHL7.model.Type type)
        {
            bool has = false;

            System.String encoded = NuGenPipeParser.encode(type, enc);
            if (encoded != null && encoded.Length > 0)
            {
                has = true;
            }
            return(has);
        }
Пример #4
0
        /// <summary>Returns true is there is content in the given segment </summary>
        private bool hasContent(Segment segment)
        {
            bool has = false;

            System.String encoded = NuGenPipeParser.encode(segment, enc);
            if (encoded != null && encoded.Length > 3)
            {
                has = true;
            }
            return(has);
        }
Пример #5
0
        /// <summary>Returns true is there is content in the given group </summary>
        private bool hasContent(Group group)
        {
            bool has = false;

            System.String encoded = NuGenPipeParser.encode(group, enc);
            if (encoded.IndexOf('|') >= 0)
            {
                has = true;
            }
            return(has);
        }
Пример #6
0
        /// <summary> Tests whether the given type falls within a maximum length.  </summary>
        /// <returns> null of OK, an HL7Exception otherwise
        /// </returns>
        public virtual NuGenHL7Exception testLength(Genetibase.NuGenHL7.model.Type type, int maxLength)
        {
            NuGenHL7Exception e = null;

            System.String encoded = NuGenPipeParser.encode(type, this.enc);
            if (encoded.Length > maxLength)
            {
                e = new NuGenProfileNotFollowedException("Length of " + encoded.Length + " exceeds maximum of " + maxLength);
            }
            return(e);
        }
Пример #7
0
        /// <summary> Tests a Type against the corresponding section of a profile.</summary>
        /// <param name="encoded">optional encoded form of type (if you want to specify this -- if null,
        /// default pipe-encoded form is used to check length and constant val)
        /// </param>
        public virtual NuGenHL7Exception[] testType(Genetibase.NuGenHL7.model.Type type, AbstractComponent profile, System.String encoded, System.String profileID)
        {
            System.Collections.ArrayList exList = new System.Collections.ArrayList();
            if (encoded == null)
            {
                encoded = NuGenPipeParser.encode(type, this.enc);
            }

            NuGenHL7Exception ue = testUsage(encoded, profile.Usage, profile.Name);

            if (ue != null)
            {
                exList.Add(ue);
            }

            if (!profile.Usage.Equals("X"))
            {
                //check datatype
                System.String typeClass = type.GetType().FullName;
                if (typeClass.IndexOf("." + profile.Datatype) < 0)
                {
                    typeClass = typeClass.Substring(typeClass.LastIndexOf('.') + 1);
                    exList.Add(new NuGenProfileNotHL7CompliantException("HL7 datatype " + typeClass + " doesn't match profile datatype " + profile.Datatype));
                }

                //check length
                if (encoded.Length > profile.Length)
                {
                    exList.Add(new NuGenProfileNotFollowedException("The type " + profile.Name + " has length " + encoded.Length + " which exceeds max of " + profile.Length));
                }

                //check constant value
                if (profile.ConstantValue != null && profile.ConstantValue.Length > 0)
                {
                    if (!encoded.Equals(profile.ConstantValue))
                    {
                        exList.Add(new NuGenProfileNotFollowedException("'" + encoded + "' doesn't equal constant value of '" + profile.ConstantValue + "'"));
                    }
                }

                NuGenHL7Exception[] te = testTypeAgainstTable(type, profile, profileID);
                for (int i = 0; i < te.Length; i++)
                {
                    exList.Add(te[i]);
                }
            }

            return(this.toArray(exList));
        }
Пример #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();
        }