Exemplo n.º 1
3
		public void ParseORMo01ToXml()
		{
			string Message = @"MSH|^~\&|INVISION|DHC|SUNQUEST LAB||200606191615||ORM^O01|ORDR|P|2.3.1|LAB
PID|0001||3020956||TRAINONLYPOE^ONE||19770903|F||W||||||||40230443
PV1|0001|I|MICU^W276^01||||045716^ABAZA, MONA M|||MED|||||||045716|F|000000030188
ORC|NW|01444^00001|||||||||||L
OBR||01444^00001||CAI^CALCIUM IONIZED|||200606191614||||L|||||045716^STEELE, ANDREW W|||||||||||00001&UNITS^ONCE&ONCE^000^200606191614^200606191614^ROUTINE
";

			PipeParser Parser = new PipeParser();

			IMessage m = Parser.Parse(Message);

			ORM_O01 ormo01 = m as ORM_O01;

			XMLParser xmlParser = new DefaultXMLParser();

			string recoveredMessage = xmlParser.Encode(ormo01);

			Assert.AreNotEqual(string.Empty, recoveredMessage);

			XmlDocument ormDoc = new XmlDocument();
			ormDoc.LoadXml(recoveredMessage);
			Assert.IsNotNull(ormDoc);
		}
Exemplo n.º 2
0
        public void ParseORMo01ToXml()
        {
            string Message = @"MSH|^~\&|INVISION|DHC|SUNQUEST LAB||200606191615||ORM^O01|ORDR|P|2.3.1|LAB
PID|0001||3020956||TRAINONLYPOE^ONE||19770903|F||W||||||||40230443
PV1|0001|I|MICU^W276^01||||045716^ABAZA, MONA M|||MED|||||||045716|F|000000030188
ORC|NW|01444^00001|||||||||||L
OBR||01444^00001||CAI^CALCIUM IONIZED|||200606191614||||L|||||045716^STEELE, ANDREW W|||||||||||00001&UNITS^ONCE&ONCE^000^200606191614^200606191614^ROUTINE
";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORM_O01 ormo01 = m as NHapi.Model.V231.Message.ORM_O01;

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(ormo01);

            Assert.AreNotEqual(string.Empty, recoveredMessage);

            System.Xml.XmlDocument ormDoc = new System.Xml.XmlDocument();
            ormDoc.LoadXml(recoveredMessage);
            Assert.IsNotNull(ormDoc);
        }
Exemplo n.º 3
0
        public void ParseORRo02ToXml()
        {
            string Message = @"MSH|^~\&|INVISION|DHC|SUNQUEST LAB||200607100719||ORR^O02|ORDR|T|2.3.1|LAB
PID|0001||3017864||HILBERT^MARY||19440823|F||W||||||||40244246
PV1|0001|O|LW||||888883^DOCTOR, UNASSIGNED||||||||||888883|O|000000031540
ORC|NA|00003^00001|F1492|||||||||888883
OBR||00003^00001|F1492|RESPC^CULTURE RESPIRATORY ROUTINE|||||||L|||||||||F1492|||||||^ONCE&ONCE^^200607070600^200607070600^ROUTINE
";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORR_O02 msg = m as NHapi.Model.V231.Message.ORR_O02;

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(msg);

            Assert.AreNotEqual(string.Empty, recoveredMessage);

            System.Xml.XmlDocument orrDoc = new System.Xml.XmlDocument();
            orrDoc.LoadXml(recoveredMessage);
            Assert.IsNotNull(orrDoc);
        }
Exemplo n.º 4
0
        public void CreateBlankMessage()
        {
            ADT_A01 a01 = new ADT_A01();
            DateTime birthDate = new DateTime(1980, 4, 1);
            a01.MSH.SendingApplication.UniversalID.Value = "ThisOne";
            a01.MSH.ReceivingApplication.UniversalID.Value = "COHIE";
            a01.PID.PatientIDExternalID.ID.Value = "123456";
            a01.PV1.AttendingDoctor.FamilyName.Value = "Jones";
            a01.PV1.AttendingDoctor.GivenName.Value = "Mike";
            a01.PID.DateOfBirth.TimeOfAnEvent.SetShortDate(birthDate);

            PipeParser parser = new PipeParser();

            string pipeMessage = parser.Encode(a01);

            Assert.IsNotNull(pipeMessage);

            IMessage test = parser.Parse(pipeMessage);
            ADT_A01 a01Test = test as ADT_A01;
            Assert.IsNotNull(a01Test);

            Assert.AreEqual(a01Test.MSH.ReceivingApplication.UniversalID.Value, "COHIE");
            Assert.AreEqual(a01Test.PID.PatientIDExternalID.ID.Value, "123456");

            Assert.AreEqual(a01Test.PID.DateOfBirth.TimeOfAnEvent.GetAsDate().ToShortDateString(), birthDate.ToShortDateString());

            Assert.AreEqual(a01Test.PV1.AttendingDoctor.FamilyName.Value, "Jones");
            Assert.AreEqual(a01Test.MSH.MessageType.MessageType.Value, "ADT");
            Assert.AreEqual(a01Test.MSH.MessageType.TriggerEvent.Value, "A01");
        }
        /// <summary>
        /// Test
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override ValidationException[] test(IMessage msg)
        {
            ValidationException[] result = new ValidationException[0];

            foreach (SegmentMandatoryRule rule in segmentRules)
            {
                bool flag1 = (rule.Version == "*") || (msg.Version == rule.Version);
                
                string structureName = msg.GetStructureName();
                string[] sNames = structureName.Split('_');
                bool flag2 = (rule.MessageType == "*") || (sNames[0] == rule.MessageType);
                bool flag3 = (rule.TriggerEvent == "*") || (sNames[1] == rule.TriggerEvent);

                if (flag1 && flag2 && flag3)
                {
                    PipeParser parser = new PipeParser();
                    if (!parser.SegmentExists(msg, rule.MadatorySegment))
                    {
                        result = new ValidationException[1] { new ValidationException(string.Format("Segment {0} not available in message", rule.MadatorySegment)) };
                    }
                }

                if (result.Count() > 0)
                    break;
            }

            return result;
        }
Exemplo n.º 6
0
        public IList<Medication> parse(string message)
        {
            PipeParser parser = new PipeParser();
            RTB_K13 rtb_k13 = (RTB_K13)parser.Parse(message);

            string responseStatus = rtb_k13.QAK.QueryResponseStatus.Value;

            if (String.Equals("NF", responseStatus, StringComparison.CurrentCultureIgnoreCase))
            {
                // TODO - see RxProfileDecoder.decode
                return null;
            }

            if (!String.Equals("OK", responseStatus, StringComparison.CurrentCultureIgnoreCase))
            {
                throw new MdoException("Received processing error: " + message);
            }

            int recordCount = Int32.Parse(rtb_k13.QAK.ThisPayload.Value);
            IList<Medication> meds = new List<Medication>();

            for (int i = 0; i < recordCount; i++)
            {
                RDT rdt = rtb_k13.ROW_DEFINITION.GetRDT(i);
                meds.Add(buildMedication(rdt));
            }

            return meds;
        }
Exemplo n.º 7
0
        public void ParseORFR04ToXmlNoNTE()
        {
            string Message = @"MSH|^~\&|Query Result Locator|Query Facility Name|Query Application Name|ST ELSEWHERE HOSPITAL|20051024074506||ORF^R04|432|P|2.3.1|
MSA|AA|123456789|
QRD|20060228160421|R|I||||10^RD&Records&0126|38923^^^^^^^^&TCH|||
QRF||20050101000000||
PID|||38923^^^ST ELSEWHERE HOSPITAL Medical Record Numbers&              MEDIC              AL RECORD NUMBER&ST ELSEWHERE HOSPITAL^MR^ST ELSEWHERE HOSPITAL||Bombadill^Tom||19450605|M|||1&Main Street^^Littleton^CO^80122||^^^^^303^4376329^22|
OBR|1|0015566|DH2211223|83036^HEMOGLOBIN A1C^^83036^HEMOGLOBIN A1C|||20040526094000|||||||20040526094000||J12345^JENS^JENNY^^^DR^MD^^^^^^^112233&TCH|||||          TP QUEST DIAGNOSTICS-TAMPA 4225 E. FOWLER AVE TAMPA          FL 33617|20030622070400|||F|
OBX|1|NM|50026400^HEMOGLOBIN A1C^^50026400^HEMOGLOBIN A1C||12|^% TOTAL HGB|4.0 - 6.0|H|||F|||20040510094000|TP^^L|";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORF_R04 orfR04 = m as NHapi.Model.V231.Message.ORF_R04;

            Assert.IsNotNull(orfR04);

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(orfR04);

            Assert.IsNotNull(recoveredMessage);
            Assert.IsFalse(recoveredMessage.IndexOf("NTE") > -1, "Returned Message added ORC segment.");
        }
Exemplo n.º 8
0
        public void ParseORFR04ToXML()
        {
            string message = @"MSH|^~\&|Query Result Locator|Query Facility Name|Query Application Name|ST ELSEWHERE HOSPITAL|20051024074506||ORF^R04|432|P|2.3|
            MSA|AA|123456789|
            QRD|20060228160421|R|I||||10^RD&Records&0126|38923^^^^^^^^&TCH|||
            QRF||20050101000000||
            PID|||38923^^^ST ELSEWHERE HOSPITAL Medical Record Numbers&              MEDIC              AL RECORD NUMBER&ST ELSEWHERE HOSPITAL^MR^ST ELSEWHERE HOSPITAL||Bombadill^Tom||19450605|M|||1&Main Street^^Littleton^CO^80122||^^^^^303^4376329^22|
            OBR|1|0015566|DH2211223|83036^HEMOGLOBIN A1C^^83036^HEMOGLOBIN A1C|||20040526094000|||||||20040526094000||J12345^JENS^JENNY^^^DR^MD^^^^^^^112233&TCH|||||          TP QUEST DIAGNOSTICS-TAMPA 4225 E. FOWLER AVE TAMPA          FL 33617|20030622070400|||F|
            OBX|1|NM|50026400^HEMOGLOBIN A1C^^50026400^HEMOGLOBIN A1C||12|^% TOTAL HGB|4.0 - 6.0|H|||F|||20040510094000|TP^^L|";

            PipeParser parser = new PipeParser();

            IMessage m = parser.Parse(message);

            ORF_R04 orfR04 = m as ORF_R04;

            Assert.IsNotNull(orfR04);

            XMLParser xmlParser = new DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(orfR04);

            Assert.IsNotNull(recoveredMessage);
            Assert.IsFalse(string.Empty.Equals(recoveredMessage));
        }
Exemplo n.º 9
0
        public static String GetHL7Event(String message)
        {
            var parser        = new NHapi.Base.Parser.PipeParser();
            var parsedMessage = parser.Parse(message);

            //Terse it!
            Terser terser = new Terser(parsedMessage);

            //Grab RequiredFields

            string sEventType   = terser.Get("/MSH-9-1");
            string sMessageType = terser.Get("/MSH-9-2");


            //Get the message type and trigger event
            var msgType = parsedMessage.GetStructureName();

            //Console.WriteLine("msg type = {0}", sMessageType); // = ADT_EVENT

            //Get the message in raw, pipe-delimited format
            var pipeDelimitedMessage = parser.Encode(parsedMessage);


            //Console.WriteLine("msg = {0}", pipeDelimitedMessage);

            return(sMessageType); //msgType; //pipeDelimitedMessage;
        }
Exemplo n.º 10
0
        public void ParseORMwithCompleteOBXToXML()
        {
            string Message = @"MSH|^~\&|INVISION|DHC|SUNQUEST LAB||200606191615||ORM^O01|ORDR|P|2.3.1|LAB
PID|0001||3020956||TRAINONLYPOE^ONE||19770903|F||W||||||||40230443
PV1|0001|I|MICU^W276^01||||045716^ABAZA, MONA M|||MED|||||||045716|F|000000030188
ORC|NW|01444^00001|||||||||||L
OBR||01444^00001||CAI^CALCIUM IONIZED|||200606191614||||L|||||045716^STEELE, ANDREW W|||||||||||00001&UNITS^ONCE&ONCE^000^200606191614^200606191614^ROUTINE
OBX|1|TX|SDES||Blood, peripheral||||||Z
OBX|2|TX|SREQ||LEFT ANTECUBITAL||||||Z
OBX|3|TX|CULT||Beta hemolytic Streptococcus Group A||||||Z
OBX|4|TX|CULT||Critical result(s) called to and verification ";

            Message += "\"read-back\"";
            Message += @" received from: Nu~||||||Z
";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORM_O01 msgObj = m as NHapi.Model.V231.Message.ORM_O01;

            Assert.IsNotNull(msgObj);

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(msgObj);

            Assert.IsNotNull(recoveredMessage);
            Assert.IsFalse(string.Empty.Equals(recoveredMessage));
        }
Exemplo n.º 11
0
        public void ParseORMwithOBXToXML()
        {
            string Message = @"MSH|^~\&|INVISION|DHC|SUNQUEST LAB||200606191615||ORM^O01|ORDR|P|2.3.1|LAB
PID|0001||3020956||TRAINONLYPOE^ONE||19770903|F||W||||||||40230443
PV1|0001|I|MICU^W276^01||||045716^ABAZA, MONA M|||MED|||||||045716|F|000000030188
ORC|NW|01444^00001|||||||||||L
OBR||01444^00001||CAI^CALCIUM IONIZED|||200606191614||||L|||||045716^STEELE, ANDREW W|||||||||||00001&UNITS^ONCE&ONCE^000^200606191614^200606191614^ROUTINE
OBX||NM|||999||||||
OBX||NM|||999||||||
OBX||NM|||999||||||";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORM_O01 msgObj = m as NHapi.Model.V231.Message.ORM_O01;

            Assert.IsNotNull(msgObj);

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(msgObj);

            Assert.IsNotNull(recoveredMessage);
            Assert.IsFalse(string.Empty.Equals(recoveredMessage));
        }
Exemplo n.º 12
0
        public void ProcessA01(string sHL7)
        {
            var parser        = new NHapi.Base.Parser.PipeParser();
            var parsedMessage = parser.Parse(sHL7);
            var a01           = parsedMessage as ADT_A01;

            string sPtName = "";

            //Terser terser;

            Terser terser = new Terser(parsedMessage);


            sPtName = terser.Get("/PID-5");
            string sFName = terser.Get("/PID-5-2");
            string sLName = terser.Get("/PID-5-1");

            //attempt parsing of a field that does not exist in transaction
            string sPatientID = terser.Get("/PID-1");

            Console.WriteLine("Patient First Name = {0}", sFName);
            Console.WriteLine("Patient Last Name = {0}", sLName);



            //var patientMR = a01.PID.PatientID.IDNumber.Value;
            //var patientAcctNo= a01.PID.PatientAccountNumber.IDNumber.Value;
            //var patientName = a01.PID.GetPatientName(0);
            //string sLName = patientName.FamilyName.Surname.Value;
            //string sFName = patientName.GivenName.Value;

            //Console.WriteLine("Patient FName = {0}", sFName);
        }
Exemplo n.º 13
0
		public void TestSpecialCharacterEntry()
		{
			PipeParser parser = new PipeParser();
			ORU_R01 oru = new ORU_R01();
			oru.MSH.MessageType.MessageType.Value = "ORU";
			oru.MSH.MessageType.TriggerEvent.Value = "R01";
			oru.MSH.EncodingCharacters.Value = @"^~\&";
			oru.MSH.VersionID.VersionID.Value = "2.3.1";
			oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION(0).OBX.ValueType.Value = "FT";
			oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).OBR.SetIDOBR.Value = "1";
			Varies v =
				oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION(0).OBX.GetObservationValue(0);
			ST text = new ST(oru);
			text.Value = @"This\.br\is\.br\A Test";
			v.Data = text;


			string encodedData = parser.Encode(oru);
			Console.WriteLine(encodedData);
			IMessage msg = parser.Parse(encodedData);
			Console.WriteLine(msg.GetStructureName());
			oru = (ORU_R01) msg;
			FT data = (FT) oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION(0).OBX.GetObservationValue(0).Data;
			Assert.AreEqual(@"This\.br\is\.br\A Test", data.Value);
		}
Exemplo n.º 14
0
        public IList<Medication> parse(string message)
        {
            PipeParser pp = new PipeParser();
            ORP_O10 orp_o10 = (ORP_O10)pp.Parse(message);
            ORP_O10_ORCRXE orp_o10_orcrxe = new ORP_O10_ORCRXE(); // ORP_O10 doesn't parse the RXE segment of the response so we need this class extension

            if (!String.Equals(((MSA)orp_o10.GetStructure("MSA")).AcknowledgementCode.Value, "AA", StringComparison.CurrentCultureIgnoreCase))
            {
                throw new mdo.exceptions.MdoException("Error in refill response: " + message);
            }

            IList<Medication> meds = new List<Medication>();
            //IStructure[] structs = orp_o10.GetAll("RXE");

            string[] lines = message.Split(new char[] { '\r' });
            IList<string> rxeLines = new List<string>();
            foreach (string line in lines)
            {
                if (String.IsNullOrEmpty(line))
                {
                    continue;
                }
                if (line.StartsWith("RXE"))
                {
                    rxeLines.Add(line);
                }
            }

            for (int i = 0; i < rxeLines.Count; i++)
            {
                meds.Add(buildMedication(getRxe(rxeLines[i], orp_o10_orcrxe.getRxe(i))));
            }

            return meds;
        }
Exemplo n.º 15
0
        public void ParseSimpleMessage()
        {
            PipeParser parser = new PipeParser();
            ADT_A01 msg = parser.Parse(GetMessage(), Constants.VERSION_25_UCH) as ADT_A01;
            Assert.IsNotNull(msg);

            Assert.AreEqual(2, msg.OBXRepetitionsUsed);
        }
Exemplo n.º 16
0
		public void TestORMDescriptionExtract()
		{
			var parser = new PipeParser();
			var results = parser.Parse(Message_ORMSample);
			var typed = results as ORM_O01;

			Assert.AreEqual(typed.PATIENT.PID.DateTimeOfBirth.Description, @"Date/Time Of Birth");
		}
Exemplo n.º 17
0
        /// <summary>
        /// Send a HL7 message
        /// </summary>
        /// <param name="message">Message to send</param>
        /// <returns>Reply message</returns>
        public IMessage SendHL7Message(IMessage message)
        {
            PipeParser parser = new PipeParser();
            string msg = parser.Encode(message);

            string reply = SendHL7Message(msg);
            return parser.Parse(reply);
        }
Exemplo n.º 18
0
		public void ConvertToDate()
		{
			DateTime checkDate = DateTime.Now;
			PipeParser parser = new PipeParser();
			ADT_A01 a01 = new ADT_A01();
			a01.PV1.AdmitDateTime.TimeOfAnEvent.Set(checkDate, "yyyyMMdd");
			Assert.AreEqual(a01.PV1.AdmitDateTime.TimeOfAnEvent.Value, checkDate.ToString("yyyyMMdd"));
		}
Exemplo n.º 19
0
		public void TestSpecialCharacterEncoding()
		{
			PipeParser parser = new PipeParser();
			ORU_R01 oru = new ORU_R01();
			oru = (ORU_R01) parser.Parse(GetMessage());

			FT data = (FT) oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION(0).OBX.GetObservationValue(0).Data;
			Assert.AreEqual(@"This\.br\is\.br\A Test", data.Value);
		}
        public void TestUch25Parse_Complex()
        {
            PipeParser parser = new PipeParser();
            ADT_A01 msg = (ADT_A01)parser.Parse(GetComplexMessage(), Constants.VERSION_25_UCH);
            Assert.IsNotNull(msg);

            Assert.AreEqual(2, msg.CON2RepetitionsUsed);
            Assert.AreEqual(5, msg.CONRepetitionsUsed);
        }
Exemplo n.º 21
0
        public void ParseSimpleMessage()
        {
            PipeParser parser = new PipeParser();
            ADT_A01 msg = parser.Parse(GetMessage(), Constants.VERSION_25_UCH) as ADT_A01;
            Assert.IsNotNull(msg);

            Assert.AreEqual(2, msg.INSURANCERepetitionsUsed);
            Assert.AreEqual(msg.GetINSURANCE(0).IN1.SetIDIN1.Value, "1");
            Assert.AreEqual(msg.GetINSURANCE(1).IN1.SetIDIN1.Value, "2");
        }
Exemplo n.º 22
0
		public void TestOBR5RepeatingValuesMessage()
		{
			var parser = new PipeParser();
			var oru = new ORU_R01();
			oru = (ORU_R01) parser.Parse(GetMessage());

			foreach (var obs in oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION().OBX.GetObservationValue())
			{
				Assert.IsTrue(obs.Data is FT);
			}
		}
Exemplo n.º 23
0
		public void TestMSH3Set()
		{
			ADT_A01 a01 = new ADT_A01();
			a01.MSH.SendingApplication.UniversalID.Value = "TEST";

			PipeParser parser = new PipeParser();
			string hl7 = parser.Encode(a01);

			string[] data = hl7.Split('|');
			Assert.AreEqual("ADT^A01", data[8]);
		}
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            PipeParser parser = new PipeParser();

            CustomHL7Implementations.V24.Message.ORU_R01 orur01 = new CustomHL7Implementations.V24.Message.ORU_R01();
            orur01.ZVC.EstadoAutorizacion.Text.Value = "1234";

            string msg = parser.Encode(orur01);

            ZVC oZVC = (ZVC)orur01.GetStructure("ZVC");
            oZVC.EstadoAutorizacion.Text.Value = "1234";
            msg = parser.Encode(orur01);
        }
Exemplo n.º 25
0
		public void TestAdtA28MappingToHl7()
		{
			ADT_A05 a05 = new ADT_A05();

			a05.MSH.MessageType.MessageCode.Value = "ADT";
			a05.MSH.MessageType.TriggerEvent.Value = "A28";
			a05.MSH.MessageType.MessageStructure.Value = "ADT_A05";
			PipeParser parser = new PipeParser();
			string msg = parser.Encode(a05);

			string[] data = msg.Split('|');
			Assert.AreEqual("ADT^A28^ADT_A05", data[8]);
		}
Exemplo n.º 26
0
        public void BuildSyndromicSurveillanceMessage_GivenProblemAndVisitKeys_Succeeds()
        {
            var keyValues = new Dictionary<string, long>
                                {
                                    { HttpHandlerQueryStrings.ProblemKey, AlbertSmithPatientClinicalCaseOneProblemThree.Key },
                                };

            var syndromicSurveillanceFactory = new Hl7SyndromicSurveillanceFactory ( SessionProvider );
            var message = syndromicSurveillanceFactory.GetHl7Message ( keyValues );
            var messageObject = new PipeParser ().Parse ( message );
            var type = (NHapi.Model.V251.Message.ADT_A01)messageObject;

            Assert.AreEqual( 1, type.DG1RepetitionsUsed);
        }
Exemplo n.º 27
0
        public void ParseQRYR02()
        {
            string Message = @"MSH|^~\&|CohieCentral|COHIE|Clinical Data Provider|TCH|20060228155525||QRY^R02^QRY_R02|1|P|2.3.1|
QRD|20060228155525|R|I||||10^RD&Records&0126|38923^^^^^^^^&TCH|||";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.QRY_R02 qryR02 = m as NHapi.Model.V231.Message.QRY_R02;

            Assert.IsNotNull(qryR02);
            Assert.AreEqual("38923", qryR02.QRD.GetWhoSubjectFilter(0).IDNumber.Value);
        }
Exemplo n.º 28
0
		public void ParseQRYR02()
		{
			string message = @"MSH|^~\&|CohieCentral|COHIE|Clinical Data Provider|TCH|20060228155525||QRY^R02^QRY_R02|1|P|2.3|
QRD|20060228155525|R|I||||10^RD&Records&0126|38923^^^^^^^^&TCH|||";

			PipeParser parser = new PipeParser();

			IMessage m = parser.Parse(message);

			QRY_R02 qryR02 = m as QRY_R02;

			Assert.IsNotNull(qryR02);
			Assert.AreEqual("38923", qryR02.QRD.GetWhoSubjectFilter(0).IDNumber.Value);
		}
Exemplo n.º 29
0
        public void BuildHl7ImmunizationMessage_GivenActivity_Succeeds()
        {
            var keyValues = new Dictionary<string, long>
                                {
                                    { HttpHandlerQueryStrings.ActivityKey, AlbertSmithPatientClinicalCaseOneVisitFourImmunizationTwo.Key },
                                };

            var hl7ImmunizationFactory = new Hl7ImmunizationFactory ( SessionProvider );
            string message = hl7ImmunizationFactory.GetHl7Message ( keyValues );
            var messageObject = new PipeParser().Parse(message);
            var vxuV04 = ( VXU_V04 ) messageObject;

            VXU_V04_ORDER order = vxuV04.GetORDER ();
            Assert.IsNotNull ( order );
        }
Exemplo n.º 30
0
		public void TestAdtA28MappingFromHl7()
		{
			string hl7Data = @"MSH|^~\&|CohieCentral|COHIE|Clinical Data Provider|TCH|20060228155525||ADT^A28^ADT_A05|1|P|2.5|
EVN|
PID|1|12345
PV1|1";
			PipeParser parser = new PipeParser();
			IMessage msg = parser.Parse(hl7Data);

			Assert.IsNotNull(msg, "Message should not be null");
			ADT_A05 a05 = (ADT_A05) msg;

			Assert.AreEqual("A28", a05.MSH.MessageType.TriggerEvent.Value);
			Assert.AreEqual("1", a05.PID.SetIDPID.Value);
		}
Exemplo n.º 31
0
		public void ParseADT_A08()
		{
			//this is some fictive data
			string message = @"MSH|^~\&|SUNS1|OVI02|AZIS|CMD|200606221348||ADT^A08|1049691900|P|2.2
EVN|A08|200601060800
PID||8912716038^^^51276|0216128^^^51276||BARDOUN^LEA SACHA||19981201|F|||AVENUE FRANC GOLD 8^^LUXEMBOURGH^^6780^150||053/12456789||N|S|||99120162652||^^^|||||B
PV1||O|^^|U|||07632^MORTELO^POL^^^DR.|^^^^^|||||N||||||0200001198
PV2|||^^AZIS||N|||200601060800
IN1|0001|2|314000|||||||||19800101|||1|BARDOUN^LEA SACHA|1|19981201|AVENUE FRANC GOLD 8^^LUXEMBOURGH^^6780^150|||||||||||||||||
ZIN|0164652011399|0164652011399|101|101|45789^Broken bone";


			/*	**********************************************************
			 * Requirements:
			 * 
			 * 1) You need to update the project's app.config <configSections>
			 * element to include the 'HL7PackageConfiguration' configuration section
			 * 
			 * <configSections>
			 * 	<section name="HL7PackageConfiguration" type="NHapi.Base.Model.Configuration.HL7PackageConfigurationSection, NHapi.Base"/>
			 * </configSections>
			 * 
			 * And then you need to add a configuration that details the namespace and
			 * custom version name so that the PipeParser can find the custom definitions:
			 * 
			 * <HL7PackageConfiguration>
			 * 	<HL7PackageCollection>
			 * 		<HL7Package name="NHapi.Model.V22_ZSegments" version="2.2.CustomZ"/>
			 * 	</HL7PackageCollection>
			 * </HL7PackageConfiguration>
			 * 
			 * 2) You need to use this PipeParse.Parse(message, version) method
			 * and use the version you defined in the app.config above.
			 * 
          * ***********************************************************/
			var parser = new PipeParser();

			IMessage m = parser.Parse(message, Constants.VERSION);

			Assert.IsNotNull(m);

			Console.WriteLine("Type: " + m.GetType());

			var adtA08 = m as ADT_A08;
			//verify some Z segment data
			Assert.AreEqual("45789", adtA08.ZIN.AccidentData.Id.Value);
			Assert.AreEqual("Broken bone", adtA08.ZIN.AccidentData.Text.Value);
		}
Exemplo n.º 32
0
		public void TestOBR5RepeatingValuesMessage_DataTypesAndRepetitions()
		{
			var parser = new PipeParser();
			var oru = new ORU_R01();
			oru = (ORU_R01) parser.Parse(GetMessage());

			int expectedObservationCount = 3;
			int parsedObservations = oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).OBSERVATIONRepetitionsUsed;
			bool parsedCorrectNumberOfObservations = parsedObservations == expectedObservationCount;
			Assert.IsTrue(parsedCorrectNumberOfObservations,
				string.Format("Expected 3 OBX repetitions used for this segment, found {0}", parsedObservations));

			foreach (var obs in oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION().OBX.GetObservationValue())
			{
				Assert.IsTrue(obs.Data is FT);
			}
		}
Exemplo n.º 33
0
        public static new void Main(System.String[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Out.WriteLine("Usage: DefaultXMLParser pipe_encoded_file");
                System.Environment.Exit(1);
            }

            //read and parse message from file
            try
            {
                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);

                ParserBase inParser = null;
                ParserBase outParser = null;
                PipeParser pp = new PipeParser();
                NHapi.Base.Parser.XMLParser xp = new DefaultXMLParser();
                System.Console.Out.WriteLine("Encoding: " + pp.GetEncoding(messString));
                if (pp.GetEncoding(messString) != null)
                {
                    inParser = pp;
                    outParser = xp;
                }
                else if (xp.GetEncoding(messString) != null)
                {
                    inParser = xp;
                    outParser = pp;
                }

                IMessage mess = inParser.Parse(messString);
                System.Console.Out.WriteLine("Got message of type " + mess.GetType().FullName);

                System.String otherEncoding = outParser.Encode(mess);
                System.Console.Out.WriteLine(otherEncoding);
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
Exemplo n.º 34
0
        public void ParseXMLToHL7()
        {
            string Message = GetQRYR02XML();

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();
            NHapi.Base.Model.IMessage   m         = xmlParser.Parse(Message);

            NHapi.Model.V231.Message.QRY_R02 qryR02 = m as NHapi.Model.V231.Message.QRY_R02;

            Assert.IsNotNull(qryR02);

            NHapi.Base.Parser.PipeParser pipeParser = new NHapi.Base.Parser.PipeParser();

            string pipeOutput = pipeParser.Encode(qryR02);

            Assert.IsNotNull(pipeOutput);
            Assert.IsFalse(string.Empty.Equals(pipeOutput));
        }
Exemplo n.º 35
0
        public override bool Send(IMessage msg)
        {
            try
            {
                string path = outputDir + GetFileName(msg);
                using (StreamWriter sw = new StreamWriter(File.OpenWrite(path)))
                {
                    PipeParser parser = new PipeParser();
                    sw.Write(parser.Encode(msg));
                }
            }
            catch (IOException)
            {
                return false;
            }

            return true;
        }
Exemplo n.º 36
0
        /// <summary>   Tests dh patient 1111111. </summary>
        public void TestDHPatient1111111()
        {
            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(GetDHPatient1111111());

            NHapi.Model.V231.Message.ORF_R04 orfR04 = m as NHapi.Model.V231.Message.ORF_R04;

            Assert.IsNotNull(orfR04);
            object range = orfR04.GetQUERY_RESPONSE().GetORDER().GetOBSERVATION().OBX.GetObservationValue(1);

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(orfR04);

            Assert.IsNotNull(recoveredMessage);
            Assert.IsFalse(recoveredMessage.IndexOf("NTE") > -1, "Returned Message added ORC segment.");
        }
Exemplo n.º 37
0
        public void ParseORFR04()
        {
            string Message = @"MSH|^~\&|Query Result Locator|Query Facility Name|Query Application Name|ST ELSEWHERE HOSPITAL|20051024074506||ORF^R04|432|P|2.3.1|
            MSA|AA|123456789|
            QRD|20060228160421|R|I||||10^RD&Records&0126|38923^^^^^^^^&TCH|||
            QRF||20050101000000||
            PID|||38923^^^ST ELSEWHERE HOSPITAL Medical Record Numbers&              MEDIC              AL RECORD NUMBER&ST ELSEWHERE HOSPITAL^MR^ST ELSEWHERE HOSPITAL||Bombadill^Tom||19450605|M|||1&Main Street^^Littleton^CO^80122||^^^^^303^4376329^22|
            OBR|1|0015566|DH2211223|83036^HEMOGLOBIN A1C^^83036^HEMOGLOBIN A1C|||20040526094000|||||||20040526094000||J12345^JENS^JENNY^^^DR^MD^^^^^^^112233&TCH|||||          TP QUEST DIAGNOSTICS-TAMPA 4225 E. FOWLER AVE TAMPA          FL 33617|20030622070400|||F|
            OBX|1|NM|50026400^HEMOGLOBIN A1C^^50026400^HEMOGLOBIN A1C||12|^% TOTAL HGB|4.0 - 6.0|H|||F|||20040510094000|TP^^L|";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORF_R04 orfR04 = m as NHapi.Model.V231.Message.ORF_R04;
            Assert.IsNotNull(orfR04);
            Assert.AreEqual("12", orfR04.GetQUERY_RESPONSE().GetORDER().GetOBSERVATION().OBX.GetObservationValue()[0].Data.ToString());
        }
Exemplo n.º 38
0
        public static String ParseMessage(String message)
        {
            var parser        = new NHapi.Base.Parser.PipeParser();
            var parsedMessage = parser.Parse(message);

            //Get the message type and trigger event
            var msgType = parsedMessage.GetStructureName();

            //Console.WriteLine("msg type = {0}", msgType); // = ADT_EVENT

            //Get the message in raw, pipe-delimited format
            var pipeDelimitedMessage = parser.Encode(parsedMessage);


            //Console.WriteLine("msg = {0}", pipeDelimitedMessage);

            return(pipeDelimitedMessage);
        }
Exemplo n.º 39
0
        public void ParseORFR04()
        {
            string Message = @"MSH|^~\&|Query Result Locator|Query Facility Name|Query Application Name|ST ELSEWHERE HOSPITAL|20051024074506||ORF^R04|432|P|2.3.1|
MSA|AA|123456789|
QRD|20060228160421|R|I||||10^RD&Records&0126|38923^^^^^^^^&TCH|||
QRF||20050101000000||
PID|||38923^^^ST ELSEWHERE HOSPITAL Medical Record Numbers&              MEDIC              AL RECORD NUMBER&ST ELSEWHERE HOSPITAL^MR^ST ELSEWHERE HOSPITAL||Bombadill^Tom||19450605|M|||1&Main Street^^Littleton^CO^80122||^^^^^303^4376329^22|
OBR|1|0015566|DH2211223|83036^HEMOGLOBIN A1C^^83036^HEMOGLOBIN A1C|||20040526094000|||||||20040526094000||J12345^JENS^JENNY^^^DR^MD^^^^^^^112233&TCH|||||          TP QUEST DIAGNOSTICS-TAMPA 4225 E. FOWLER AVE TAMPA          FL 33617|20030622070400|||F|
OBX|1|NM|50026400^HEMOGLOBIN A1C^^50026400^HEMOGLOBIN A1C||12|^% TOTAL HGB|4.0 - 6.0|H|||F|||20040510094000|TP^^L|";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORF_R04 orfR04 = m as NHapi.Model.V231.Message.ORF_R04;
            Assert.IsNotNull(orfR04);
            Assert.AreEqual("12", orfR04.GetQUERY_RESPONSE().GetORDER().GetOBSERVATION().OBX.GetObservationValue()[0].Data.ToString());
        }
Exemplo n.º 40
0
		public void TestStrictValidation_NegativeNumber(string message)
		{
			var parser = new PipeParser();
			ORU_R01 oru;

			// default validation context should pass with no exceptions
			oru = (ORU_R01) parser.Parse(message);
			foreach (var obs in oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION().OBX.GetObservationValue())
			{
				Assert.IsTrue(obs.Data is SI);
			}

			// strict validation context should throw a DataTypeException for negative number values in a SI field.
			parser.ValidationContext = new StrictValidation();
			Assert.Throws<DataTypeException>(() => { oru = (ORU_R01) parser.Parse(message); },
				string.Format("Strict validation should throw a {0} when parsing a SI field with a negative value",
					typeof (DataTypeException).Name));
		}
Exemplo n.º 41
0
        public void ParseORUr01LongToXml()
        {
            string Message = @"MSH|^~\$|LAB|DHC|LCR|DH|200511291403||ORU^R01|52780002432|P|2.3.1
PID|0001|3013839|40206609||BARNES^TEST||19551005|F|||||||||||258452152
OBR||00009^001|W442|CBC^CBC|||200509210520||||||||CBC^CBC|117564^STEEL||||||||DAH
OBX|1|NM|WBC||20.0|k/uL|4.5-10.0|H|||Z
OBX|1|TX|WBC|1|(Ref Range: 4 k/uL)|k/uL|4.5-10.0||||Z
OBX|2|NM|RBC||4.00|M/uL|4.20-5.40|L|||Z
OBX|2|TX|RBC|1|(Ref Range: 4 M/uL)|M/uL|4.20-5.40||||Z
OBX|3|NM|HGB||12.0|g/dL|14.0-24.0|L|||Z
OBX|3|TX|HGB|1|(Ref Range: 1 g/dL)|g/dL|14.0-24.0||||Z
OBX|4|NM|HCT||41.0|%|37.0-47.0||||Z
OBX|4|TX|HCT|1|(Ref Range: 3 %)|%|37.0-47.0||||Z
OBX|5|NM|MCV||80.9|fl|80.0-100.0||||Z
OBX|5|TX|MCV|1|(Ref Range: 8 fl)|fl|80.0-100.0||||Z
OBX|6|NM|MCH||31.0|pg|27.0-31.0||||Z
OBX|6|TX|MCH|1|(Ref Range: 2 pg)|pg|27.0-31.0||||Z
OBX|7|NM|MCHC||32.0|g/dL|32.0-36.0||||Z
OBX|7|TX|MCHC|1|(Ref Range: 3 g/dL)|g/dL|32.0-36.0||||Z
OBX|8|NM|RDW||19.0|%|11.5-14.5|H|||Z
OBX|8|TX|RDW|1|(Ref Range: 1 %)|%|11.5-14.5||||Z
OBX|9|NM|PLTC||45|k/uL|150-400|PL^Y|||Z
OBX|9|TX|PLTC|1|(Ref Range: 1 k/uL)|k/uL|150-400||||Z
OBX|10|NM|MPV||10.0|fL|6.2-10.0||||Z
OBX|10|TX|MPV|1|(Ref Range: 6 fL)|fL|6.2-10.0||||Z
";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORU_R01 msg = m as NHapi.Model.V231.Message.ORU_R01;

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(msg);

            Assert.AreNotEqual(string.Empty, recoveredMessage);

            System.Xml.XmlDocument orrDoc = new System.Xml.XmlDocument();
            orrDoc.LoadXml(recoveredMessage);
            Assert.IsNotNull(orrDoc);
        }
Exemplo n.º 42
0
		public void ParseADTA01()
		{
			string message = @"MSH|^~\&|ADT|Admitting|RADIO|ARTEFACT|200710061035||ADT^A01|00000040|P|2.1
EVN|A01|200710061035
PID||1144270^4^M10|0699999^2^M10||XXXXXX|XXXCXCXX|20071006|F|||10 THE ADDRESS||(450)999-9999|||S||||||||||||||N
NK1|1
PV1||I|19^D415^01P|05|07008496||180658^DOCTOR NAME|||81|||||||180658^DOCTOR NAME|NN||01||||||||||||||||||||||||200710061018
DG1|1|I9|412|NAISSANCE||01
Z01|1||S|NOUVEAU-NE||FATHER NAME^D|||||0||||A||||||N|||1|GFATHER NAME|G-PERE||(450)432-9999|21||S||20071006101800||N||0||||0000000000||||||||00000000000000|00000000||||||||||01|00000000|00000000000000|05|00|75017|00|00|||||||||||||||||||000000000|000000000|||00000000000000|||01|0";

			PipeParser parser = new PipeParser();

			IMessage m = parser.Parse(message);

			ADT_A01 parsedMessage = m as ADT_A01;

			Assert.IsNotNull(parsedMessage);
			Assert.AreEqual("1144270", parsedMessage.PID.PATIENTIDEXTERNALEXTERNALID.IDNumber.Value);
		}
Exemplo n.º 43
0
		public void Test_251DataTypesParseCorrectly(string message)
		{
			var parser = new PipeParser();
			var oru = new ORU_R01();
			oru = (ORU_R01)parser.Parse(message);

			int expectedObservationCount = 3;
			int parsedObservations = oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).OBSERVATIONRepetitionsUsed;
			bool parsedCorrectNumberOfObservations = parsedObservations == expectedObservationCount;
			Assert.IsTrue(parsedCorrectNumberOfObservations,
				string.Format("Expected {1} OBX repetitions used for this segment, found {0}", parsedObservations, expectedObservationCount));

			int index = 0;
			var obs = oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION(index).OBX.GetObservationValue().FirstOrDefault();
			Assert.IsTrue(obs.Data is DT);
			index++;
			obs = oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION(index).OBX.GetObservationValue().FirstOrDefault();
			Assert.IsTrue(obs.Data is ST);
			index++;
			obs = oru.GetPATIENT_RESULT(0).GetORDER_OBSERVATION(0).GetOBSERVATION(index).OBX.GetObservationValue().FirstOrDefault();
			Assert.IsTrue(obs.Data is TM);
		}
Exemplo n.º 44
0
        public void ParseORMo01PIDSegment()
        {
            string Message = @"MSH|^~\&|INVISION|DHC|SUNQUEST LAB||200606191615||ORM^O01|ORDR|P|2.3.1|LAB
PID|0001||3020956||TRAINONLYPOE^ONE||19770903|F||W||||||||40230443
PV1|0001|I|MICU^W276^01||||045716^ABAZA, MONA M|||MED|||||||045716|F|000000030188
ORC|NW|01444^00001|||||||||||L
OBR||01444^00001||CAI^CALCIUM IONIZED|||200606191614||||L|||||045716^STEELE, ANDREW W|||||||||||00001&UNITS^ONCE&ONCE^000^200606191614^200606191614^ROUTINE
";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORM_O01 ormo01 = m as NHapi.Model.V231.Message.ORM_O01;

            Assert.IsNotNull(ormo01);
            Assert.AreEqual("TRAINONLYPOE", (ormo01.PATIENT.PID.GetPatientName()[0]).FamilyLastName.FamilyName.Value);
            Assert.AreEqual("19770903", ormo01.PATIENT.PID.DateTimeOfBirth.TimeOfAnEvent.Value);
            Assert.AreEqual("F", ormo01.PATIENT.PID.Sex.Value);
            Assert.AreEqual("W", ((ormo01.PATIENT.PID.GetRace()[0]).Identifier.Value));

            Assert.AreEqual("ABAZA, MONA M", ormo01.PATIENT.PATIENT_VISIT.PV1.GetAttendingDoctor(0).FamilyLastName.FamilyName.Value);
        }
Exemplo n.º 45
0
        /// <summary>
        /// Asserts the message is Er7 Encoded.
        /// </summary>
        /// <param name="message">Message to be examined.</param>
        /// <exception cref="ArgumentException">
        /// If the message is less than 4 characters long or the message does not start with MSH.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// If the 4th character of each segment was not a field delimiter.
        /// </exception>
        public static void AssertEr7Encoded(string message)
        {
            // quit if the string is too short
            if (message.Length < 4)
            {
                throw new ArgumentException("The message is less than 4 characters long");
            }

            // string should start with "MSH"
            if (!message.StartsWith("MSH"))
            {
                throw new ArgumentException("The message does not start with MSH");
            }

            // 4th character of each segment should be field delimiter
            var fourthChar = message[3];
            var tokens     = message.Split(Convert.ToChar(PipeParser.SegmentDelimiter));

            for (var i = 0; i < tokens.Length; i++)
            {
                var token = tokens[i];
                if (token.Length > 0)
                {
                    if (char.IsWhiteSpace(token[0]))
                    {
                        token = PipeParser.StripLeadingWhitespace(token);
                    }

                    if (token.Length >= 4 && token[3] != fourthChar)
                    {
                        throw new InvalidOperationException(
                                  $"The 4th character should have been a {token[3]}, but it was a {fourthChar}");
                    }
                }
            }
        }
Exemplo n.º 46
0
        public void ProcessADT(string sHL7)
        {
            var parser        = new NHapi.Base.Parser.PipeParser();
            var parsedMessage = parser.Parse(sHL7);

            //Terse it!
            Terser terser = new Terser(parsedMessage);

            //Grab RequiredFields

            ///PID-11(0)-1 = grabs first repetition of PID11
            ///PID-11(1)-1 = grabs second repetition of PID11

            string   sEventType             = terser.Get("/MSH-9-1");
            string   sMessageType           = terser.Get("/MSH-9-2");
            string   sSendingFac            = terser.Get("/MSH-4");
            string   sControlID             = terser.Get("/MSH-10");
            string   sHL7DateTime           = ConvertHL7Date(terser.Get("/MSH-7"));
            DateTime dtHL7Message           = Convert.ToDateTime(sHL7DateTime);
            string   sEventDateTime         = ConvertHL7Date(terser.Get("/EVN-2"));
            DateTime dtEventDateTime        = Convert.ToDateTime(sEventDateTime);
            string   sEventReason           = terser.Get("/EVN-4");
            string   sOperatorID            = terser.Get("/EVN-5-1");
            string   sOperatorFName         = terser.Get("/EVN-5-3");
            string   sOperatorLName         = terser.Get("/EVN-5-2");
            string   sOperatorAssigningAuth = terser.Get("/EVN-5-9");
            string   sOperatorAssigningFac  = terser.Get("/EVN-5-14");
            string   sMedRecNumber          = terser.Get("/PID-3");
            string   sPtFName       = terser.Get("/PID-5-2");
            string   sPtLName       = terser.Get("/PID-5-1");
            string   sPtMName       = terser.Get("/PID-5-3");
            string   sConvertDOB    = ConvertHL7Date(terser.Get("/PID-7"), false);
            DateTime dtDOB          = Convert.ToDateTime(sConvertDOB);
            string   sSex           = terser.Get("/PID-8");
            string   sRace          = terser.Get("/PID-10");
            string   sStreetAddress = terser.Get("/PID-11-1");
            string   sCity          = terser.Get("/PID-11-3");
            string   sState         = terser.Get("/PID-11-4");
            string   sZip           = terser.Get("/PID-11-5");
            string   sCountry       = terser.Get("/PID-11-6");
            string   sVisitNumber   = terser.Get("/PID-18-1");
            string   sPtClass       = terser.Get("/PV1-2");
            string   sPtUnit        = terser.Get("/PV1-3-1");
            string   sPtRoom        = terser.Get("/PV1-3-2");
            string   sPtBed         = terser.Get("/PV1-3-3");
            string   sHospSvc       = terser.Get("/PV1-10");


            //Console.WriteLine("Date = {0}", sHL7DateTime);


            Console.WriteLine("Event Type = {0}", sEventType);
            Console.WriteLine("Message Type = {0}", sMessageType);
            Console.WriteLine("ControlID = {0}", sControlID);
            Console.WriteLine("MedRecNumber = {0}", sMedRecNumber);
            Console.WriteLine("VisitNumber = {0}", sVisitNumber);
            Console.WriteLine("Patient First Name = {0}", sPtFName);
            Console.WriteLine("Patient Last Name = {0}", sPtLName);
            Console.WriteLine("Patient Middle Name = {0}", sPtMName);
            Console.WriteLine("Patient DOB = {0}", sConvertDOB);
            Console.WriteLine("Sex = {0}", sSex);
            Console.WriteLine("Race = {0}", sRace);
            Console.WriteLine("Street = {0}", sStreetAddress);
            Console.WriteLine("City = {0}", sCity);
            Console.WriteLine("State = {0}", sState);
            Console.WriteLine("Zip = {0}", sZip);
            Console.WriteLine("Country = {0}", sCountry);
            Console.WriteLine("Patient Class = {0}", sPtClass);
            Console.WriteLine("Unit = {0}", sPtUnit);
            Console.WriteLine("Room = {0}", sPtRoom);
            Console.WriteLine("Bed = {0}", sPtBed);
            Console.WriteLine("Event DT = {0}", sEventDateTime);
            Console.WriteLine("Message DT = {0}", sHL7DateTime);
            Console.WriteLine("OperID = {0}", sOperatorID);
            Console.WriteLine("OperFName = {0}", sOperatorFName);
            Console.WriteLine("OperLName = {0}", sOperatorLName);
            Console.WriteLine("OperAuth = {0}", sOperatorAssigningAuth);
            Console.WriteLine("OperFac = {0}", sOperatorAssigningFac);

            // insert into SQL

            // As per my supervisors coding direction heheh
            //SqlConnection oConn = new SqlConnection(HL7Listener.Properties.Settings.Default.connectionStr);
            SqlCommand oComm = new SqlCommand();

            oComm.CommandType = CommandType.StoredProcedure;
            oComm.CommandText = "uspInsertADTdata";
            //

            oComm.Parameters.Add("@MessageType", SqlDbType.NVarChar).Value     = sMessageType;
            oComm.Parameters.Add("@EventType", SqlDbType.NVarChar).Value       = sEventType;
            oComm.Parameters.Add("@DateOfMessage", SqlDbType.DateTime).Value   = dtHL7Message;
            oComm.Parameters.Add("@EventDate", SqlDbType.DateTime).Value       = dtEventDateTime;
            oComm.Parameters.Add("@SendingFacility", SqlDbType.NVarChar).Value = sSendingFac;

            oComm.Parameters.Add("@EventReason", SqlDbType.NVarChar).Value       = sEventReason;
            oComm.Parameters.Add("@OperatorId", SqlDbType.NVarChar).Value        = sOperatorID;
            oComm.Parameters.Add("@OperatorFirstName", SqlDbType.NVarChar).Value = sOperatorFName;
            oComm.Parameters.Add("@OperatorLastName", SqlDbType.NVarChar).Value  = sOperatorLName;
            oComm.Parameters.Add("@OperatorAuthority", SqlDbType.NVarChar).Value = sOperatorAssigningAuth;
            oComm.Parameters.Add("@OperatorFacility", SqlDbType.NVarChar).Value  = sOperatorAssigningFac;

            oComm.Parameters.Add("@MedicalRecordNumber", SqlDbType.NVarChar).Value = sMedRecNumber;
            oComm.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value           = sPtFName;
            oComm.Parameters.Add("@LastName", SqlDbType.NVarChar).Value            = sPtLName;
            oComm.Parameters.Add("@MiddleName", SqlDbType.NVarChar).Value          = sPtMName;
            oComm.Parameters.Add("@DateOfBirth", SqlDbType.DateTime).Value         = dtDOB;
            oComm.Parameters.Add("@Sex", SqlDbType.NVarChar).Value             = sSex;
            oComm.Parameters.Add("@Race", SqlDbType.NVarChar).Value            = sRace;
            oComm.Parameters.Add("@StreetAddress", SqlDbType.NVarChar).Value   = sStreetAddress;
            oComm.Parameters.Add("@City", SqlDbType.NVarChar).Value            = sCity;
            oComm.Parameters.Add("@State", SqlDbType.NVarChar).Value           = sState;
            oComm.Parameters.Add("@ZipCode", SqlDbType.NVarChar).Value         = sZip;
            oComm.Parameters.Add("@Country", SqlDbType.NVarChar).Value         = "USA"; //sCountry;
            oComm.Parameters.Add("@VisitNumber", SqlDbType.NVarChar).Value     = sVisitNumber;
            oComm.Parameters.Add("@PatientClass", SqlDbType.NVarChar).Value    = sPtClass;
            oComm.Parameters.Add("@PatientUnit", SqlDbType.NVarChar).Value     = sPtUnit;
            oComm.Parameters.Add("@PatientRoom", SqlDbType.NVarChar).Value     = sPtRoom;
            oComm.Parameters.Add("@PatientBed", SqlDbType.NVarChar).Value      = sPtBed;
            oComm.Parameters.Add("@HospitalService", SqlDbType.NVarChar).Value = sHospSvc;
            oComm.Parameters.Add("@ControlId", SqlDbType.NVarChar).Value       = sControlID;

            oComm.Connection = oConn;



            try
            {
                if (oConn.State != ConnectionState.Open)
                {
                    oConn.Open();
                }

                oComm.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                LogSQLError(ex.ToString(), sHL7);
                Console.WriteLine("SQL Error Occurred and was logged");

                //send NAK
                bNAK = true;
            }
            finally
            {
                // need to do this on dispose of class obj (so db conn is not called billions of times)!

                //oConn.Close();
                //oConn.Dispose();
            }
        }
Exemplo n.º 47
0
 public AnonymousClassPredicate1(string name, PipeParser enclosingInstance)
 {
     Name = name;
     Enclosing_Instance = enclosingInstance;
 }
Exemplo n.º 48
0
 public AnonymousClassPredicate(PipeParser enclosingInstance)
 {
     Enclosing_Instance = enclosingInstance;
 }
Exemplo n.º 49
0
        public void ParseORFR04FromDHTest()
        {
            string Message = @"MSH|^~\&|Clinical Data Provider|DHHA|COHIECentral|COHIE|200609221408||ORF^R04||P|2.3.1
MSA|AA|
PID|2019877||2019877^^^DH^MR||LOPEZ1^JAMES^TRISTAN||19740804|M
OBR||00677^001|M428|CBC^CBC|||200511071505||||||||CBC^CBC|045716^STEELE||||||||DAH
OBX|1|NM|WBC||1.1|k/uL|5.0-16.0|L|||C
OBX|1|TX|WBC|1|(Ref Range: 5 k/uL)|k/uL|5.0-16.0||||C
OBX|1|TX|WBC||Result(s) called to and verification read-back received from:  NURSE NAN M~||||||C
OBX|1|TX|WBC||ICU 13:39 11  19  05||||||C
OBX|1|TX|WBC||Corrected on 11/29 AT 1337: Previously reported as: 1.1||||||C
OBX|2|NM|RBC||3.99|M/uL|3.80-5.40||||Z
OBX|2|TX|RBC|1|(Ref Range: 3 M/uL)|M/uL|3.80-5.40||||Z
OBX|3|NM|HGB||13.0|g/dL|14.0-24.0|L|||Z
OBX|3|TX|HGB|1|(Ref Range: 1 g/dL)|g/dL|14.0-24.0||||Z
OBX|4|NM|HCT||40.0|%|31.0-43.0||||Z
OBX|4|TX|HCT|1|(Ref Range: 3 %)|%|31.0-43.0||||Z
OBX|5|NM|MCV||80.0|fl|70.0-90.0||||Z
OBX|5|TX|MCV|1|(Ref Range: 7 fl)|fl|70.0-90.0||||Z
OBX|6|NM|MCH||32.0|pg|27.0-31.0|H|||Z
OBX|6|TX|MCH|1|(Ref Range: 2 pg)|pg|27.0-31.0||||Z
OBX|7|NM|MCHC||32.0|g/dL|32.0-36.0||||Z
OBX|7|TX|MCHC|1|(Ref Range: 3 g/dL)|g/dL|32.0-36.0||||Z
OBX|8|NM|RDW||17.0|%|11.5-14.5|H|||Z
OBX|8|TX|RDW|1|(Ref Range: 1 %)|%|11.5-14.5||||Z
OBX|9|NM|PLTC||2|k/uL|150-400|PL^Y|||Z
OBX|9|TX|PLTC|1|(Ref Range: 1 k/uL)|k/uL|150-400||||Z
OBX|10|NM|MPV||10.0|fL|6.2-10.0||||Z
OBX|10|TX|MPV|1|(Ref Range: 6 fL)|fL|6.2-10.0||||Z
OBR||00677^001|M428|CBC^CBC|||200511071505||||||||CBC^CBC|045716^STEELE||||||||DAH
OBX|1|NM|WBC||1.1|k/uL|5.0-16.0|L|||C
OBX|1|TX|WBC|1|(Ref Range: 5 k/uL)|k/uL|5.0-16.0||||C
OBX|1|TX|WBC||Result(s) called to and verification read-back received from:  NURSE NAN M~||||||C
OBX|1|TX|WBC||ICU 13:39 11  19  05||||||C
OBX|1|TX|WBC||Corrected on 11/29 AT 1337: Previously reported as: 1.1||||||C
OBX|2|NM|RBC||3.99|M/uL|3.80-5.40||||Z
OBX|2|TX|RBC|1|(Ref Range: 3 M/uL)|M/uL|3.80-5.40||||Z
OBX|3|NM|HGB||13.0|g/dL|14.0-24.0|L|||Z
OBX|3|TX|HGB|1|(Ref Range: 1 g/dL)|g/dL|14.0-24.0||||Z
OBX|4|NM|HCT||40.0|%|31.0-43.0||||Z
OBX|4|TX|HCT|1|(Ref Range: 3 %)|%|31.0-43.0||||Z
OBX|5|NM|MCV||80.0|fl|70.0-90.0||||Z
OBX|5|TX|MCV|1|(Ref Range: 7 fl)|fl|70.0-90.0||||Z
OBX|6|NM|MCH||32.0|pg|27.0-31.0|H|||Z
OBX|6|TX|MCH|1|(Ref Range: 2 pg)|pg|27.0-31.0||||Z
OBX|7|NM|MCHC||32.0|g/dL|32.0-36.0||||Z
OBX|7|TX|MCHC|1|(Ref Range: 3 g/dL)|g/dL|32.0-36.0||||Z
OBX|8|NM|RDW||17.0|%|11.5-14.5|H|||Z
OBX|8|TX|RDW|1|(Ref Range: 1 %)|%|11.5-14.5||||Z
OBX|9|NM|PLTC||2|k/uL|150-400|PL^Y|||Z
OBX|9|TX|PLTC|1|(Ref Range: 1 k/uL)|k/uL|150-400||||Z
OBX|10|NM|MPV||10.0|fL|6.2-10.0||||Z
OBX|10|TX|MPV|1|(Ref Range: 6 fL)|fL|6.2-10.0||||Z
OBR||00677^001|M428|CBC^CBC|||200511071505||||||||CBC^CBC|045716^STEELE||||||||DAH
OBX|1|NM|WBC||1.1|k/uL|5.0-16.0|L|||C
OBX|1|TX|WBC|1|(Ref Range: 5 k/uL)|k/uL|5.0-16.0||||C
OBX|1|TX|WBC||Result(s) called to and verification read-back received from:  NURSE NAN M~||||||C
OBX|1|TX|WBC||ICU 13:39 11  19  05||||||C
OBX|1|TX|WBC||Corrected on 11/29 AT 1337: Previously reported as: 1.1||||||C
OBX|2|NM|RBC||3.99|M/uL|3.80-5.40||||Z
OBX|2|TX|RBC|1|(Ref Range: 3 M/uL)|M/uL|3.80-5.40||||Z
OBX|3|NM|HGB||13.0|g/dL|14.0-24.0|L|||Z
OBX|3|TX|HGB|1|(Ref Range: 1 g/dL)|g/dL|14.0-24.0||||Z
OBX|4|NM|HCT||40.0|%|31.0-43.0||||Z
OBX|4|TX|HCT|1|(Ref Range: 3 %)|%|31.0-43.0||||Z
OBX|5|NM|MCV||80.0|fl|70.0-90.0||||Z
OBX|5|TX|MCV|1|(Ref Range: 7 fl)|fl|70.0-90.0||||Z
OBX|6|NM|MCH||32.0|pg|27.0-31.0|H|||Z
OBX|6|TX|MCH|1|(Ref Range: 2 pg)|pg|27.0-31.0||||Z
OBX|7|NM|MCHC||32.0|g/dL|32.0-36.0||||Z
OBX|7|TX|MCHC|1|(Ref Range: 3 g/dL)|g/dL|32.0-36.0||||Z
OBX|8|NM|RDW||17.0|%|11.5-14.5|H|||Z
OBX|8|TX|RDW|1|(Ref Range: 1 %)|%|11.5-14.5||||Z
OBX|9|NM|PLTC||2|k/uL|150-400|PL^Y|||Z
OBX|9|TX|PLTC|1|(Ref Range: 1 k/uL)|k/uL|150-400||||Z
OBX|10|NM|MPV||10.0|fL|6.2-10.0||||Z
OBX|10|TX|MPV|1|(Ref Range: 6 fL)|fL|6.2-10.0||||Z";

            NHapi.Base.Parser.PipeParser Parser = new NHapi.Base.Parser.PipeParser();

            NHapi.Base.Model.IMessage m = Parser.Parse(Message);

            NHapi.Model.V231.Message.ORF_R04 orfR04 = m as NHapi.Model.V231.Message.ORF_R04;

            Assert.IsNotNull(orfR04);

            NHapi.Base.Parser.XMLParser xmlParser = new NHapi.Base.Parser.DefaultXMLParser();

            string recoveredMessage = xmlParser.Encode(orfR04);

            Assert.IsNotNull(recoveredMessage);
            Assert.IsFalse(recoveredMessage.IndexOf("NTE") > -1, "Returned Message added ORC segment.");
        }
Exemplo n.º 50
0
 public AnonymousClassPredicate(PipeParser enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
Exemplo n.º 51
0
 private void InitBlock(PipeParser enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Exemplo n.º 52
0
 public AnonymousClassPredicate1(System.String name, PipeParser enclosingInstance)
 {
     InitBlock(name, enclosingInstance);
 }
Exemplo n.º 53
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
            {
                PipeParser         parser      = new PipeParser();
                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(cbuf, 0, cbuf.Length) + " of " + fileLength + " chars");
                r.Close();
                System.String messString = System.Convert.ToString(cbuf);
                IMessage      mess       = parser.Parse(messString);
                System.Console.Out.WriteLine("Got message of type " + mess.GetType().FullName);

                NHapi.Base.Parser.XMLParser 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++)
                {
                    IStructure[] reps = mess.GetAll(structNames[i]);
                    for (int j = 0; j < reps.Length; j++)
                    {
                        if (typeof(ISegment).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((ISegment)reps[j], root);
                            System.IO.StringWriter out_Renamed = new System.IO.StringWriter();
                            System.Console.Out.WriteLine(
                                "Segment " + reps[j].GetType().FullName + ": \r\n" + doc.OuterXml);

                            System.Type[]   segmentConstructTypes = { typeof(IMessage) };
                            System.Object[] segmentConstructArgs  = { null };
                            ISegment        s =
                                (ISegment)
                                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();
                            System.Xml.XmlWriter   ser  = System.Xml.XmlWriter.Create(out2);
                            doc.WriteTo(ser);
                            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);
                            }
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
Exemplo n.º 54
0
 private void InitBlock(System.String name, PipeParser enclosingInstance)
 {
     this.name = name;
     this.enclosingInstance = enclosingInstance;
 }
Exemplo n.º 55
0
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Out.WriteLine("Usage: XMLParser pipe_encoded_file");
                Environment.Exit(1);
            }

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

                XMLParser xp = new AnonymousClassXMLParser();

                // loop through segment children of message, encode, print to console
                var structNames = mess.Names;
                for (var i = 0; i < structNames.Length; i++)
                {
                    var reps = mess.GetAll(structNames[i]);
                    for (var j = 0; j < reps.Length; j++)
                    {
                        if (reps[j] is ISegment)
                        {
                            // ignore groups
                            var docBuilder = new XmlDocument();
                            var doc        = new XmlDocument(); // new doc for each segment
                            var root       = doc.CreateElement(reps[j].GetType().FullName);
                            doc.AppendChild(root);
                            xp.Encode((ISegment)reps[j], root);
                            var out_Renamed = new StringWriter();
                            Console.Out.WriteLine("Segment " + reps[j].GetType().FullName + ": \r\n" + doc.OuterXml);

                            var segmentConstructTypes = new Type[] { typeof(IMessage) };
                            var segmentConstructArgs  = new object[] { null };
                            var s = (ISegment)reps[j].GetType().GetConstructor(segmentConstructTypes).Invoke(segmentConstructArgs);
                            xp.Parse(s, root);
                            var doc2  = new XmlDocument();
                            var root2 = doc2.CreateElement(s.GetType().FullName);
                            doc2.AppendChild(root2);
                            xp.Encode(s, root2);
                            var out2 = new StringWriter();
                            var ser  = XmlWriter.Create(out2);
                            doc.WriteTo(ser);
                            if (out2.ToString().Equals(out_Renamed.ToString()))
                            {
                                Console.Out.WriteLine("Re-encode OK");
                            }
                            else
                            {
                                Console.Out.WriteLine(
                                    $"Warning: XML different after parse and re-encode: {Environment.NewLine}{out2}");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }