Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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");
        }
Ejemplo n.º 4
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);
		}
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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]);
		}
Ejemplo n.º 7
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]);
		}
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public override bool Send(IMessage msg)
        {
            bool result = true; 
            EditMessageHeader(msg);

            try
            {
                PipeParser parser = new PipeParser();
                string res = SendRequest(parser.Encode(msg));
                IMessage response = parser.Parse(res);

                Terser terser = new Terser(response);
                string ackCode = terser.Get("/MSA-1");
                result = (ackCode == "AA");
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("Error in delivering message '{0}' to Http endpoint with uri '{1}'. Error: {2}", msg.GetStructureName(), serverUri, ex.Message);
                result = false;
            }

            return result;
        }
Ejemplo n.º 12
0
 public override string ToString()
 {
     PipeParser parser = new PipeParser(new DefaultModelClassFactory());
     return parser.Encode(this);
 }
Ejemplo n.º 13
0
		public void TestPopulateEVNSegmenValuesGenerically()
		{
			string message = @"MSH|^~\&|SUNS1|OVI02|AZIS|CMD|200606221348||ADT^A01|1049691900|P|2.3
EVN|A01|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";

			var parser = new PipeParser();
			var abstractMessage = parser.Parse(message);
					
			// this is the normal / expected way of working with NHapi parsed messages
			var typedMessage = abstractMessage as ADT_A01;
			if (typedMessage != null)
			{
				typedMessage.EVN.OperatorID.FamilyName.Value = "Surname";
				typedMessage.EVN.OperatorID.GivenName.Value = "Firstname";
			}

			var pipeDelimitedMessage = parser.Encode(typedMessage);

			// alternatively, you can apply this modification to any HL7 2.3 message
			// with an EVN segment using this more generic method
			var genericMethod = abstractMessage as AbstractMessage;
			var evn = genericMethod.GetStructure("EVN") as EVN;
			if (evn != null)
			{
				evn.OperatorID.FamilyName.Value = "SurnameGeneric";
				evn.OperatorID.GivenName.Value = "FirstnameGeneric";
			}

			pipeDelimitedMessage = parser.Encode(typedMessage);
		}
Ejemplo n.º 14
0
        public void ParseXMLToHL7()
        {
            string message = GetQRYR02XML();

            XMLParser xmlParser = new DefaultXMLParser();
            IMessage m = xmlParser.Parse(message);

            QRY_R02 qryR02 = m as QRY_R02;

            Assert.IsNotNull(qryR02);

            PipeParser pipeParser = new PipeParser();

            string pipeOutput = pipeParser.Encode(qryR02);

            Assert.IsNotNull(pipeOutput);
            Assert.IsFalse(string.Empty.Equals(pipeOutput));
        }
Ejemplo n.º 15
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));
        }
Ejemplo n.º 16
0
		public void TestValidHl7Data()
		{
			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 = @"Th&is\.br\is\.br\A T|est\";
			v.Data = text;


			string encodedData = parser.Encode(oru);

			//Console.WriteLine(encodedData);
			string[] segs = encodedData.Split('\r');
			string[] fields = segs[2].Split('|');
			string data = fields[5];

			Assert.AreEqual(@"Th\T\is\.br\is\.br\A T\F\est\E\", data);
		}
Ejemplo n.º 17
0
        internal IList<Medication> refillMeds(IList<string> medsToRefill)
        {
            OMP_O09_PID omp_o09 = new OMP_O09_PID();

            fillMshSegment(omp_o09.MSH, HL7Constants.FIELD_SEPARATOR.ToString(), "MHV EVAULT", "200MHS", "127.0.0.1", "DNS", "MHV VISTA",
                _cxn.DataSource.SiteId.Id, _cxn.DataSource.Provider, "DNS", "", "OMP", "O09", "OMP_O09", "", "P", "2.4");
            addIdToPID(omp_o09.getPid(), _cxn.Pid, 1, "", "");
            buildRxeAndOrcSegments(omp_o09, medsToRefill);

            PipeParser pp = new PipeParser();
            string request = pp.Encode(omp_o09);
            System.Console.WriteLine(request);
            //string response = (string)_cxn.query(request);
            //return new RxRefillDecoder().parse(response);
            throw new NotImplementedException("This function needs to be completed.");
        }
        public string GetAcknowlegement(IMessage message)
        {
            var ackMessage = (ACK)MakeACK(message, "AA");

            var parser = new PipeParser();
            return parser.Encode(ackMessage);
        }