nHapiNET / nHapi

nHapi is the .Net port of the original Java project HAPI.
Mozilla Public License 2.0
272 stars 155 forks source link

Exception adding an escaped string as field to Segment #414

Closed manosg80 closed 1 year ago

manosg80 commented 1 year ago

Describe the bug I was trying to find out why it throws an exception when adding a particular field to header so I broke down the string to p1 and p2.

To Reproduce Just run the following code:

 Segment mshSegment = new Segment("MSH", new HL7Encoding());
            mshSegment.AddNewField("|", 1);
            string p1 = @"^~\";
            string p2 = @"&";
            string p3 = p1 + p2;
            mshSegment.AddNewField(p3, 2); 

Expected behaviour Should add the field

Screenshots image

Sample HL7 If applicable, add a sample hl7 message to help highlight your problem.

Environmental Details (please complete the following information):

Additional context Add any other context about the problem here.

manosg80 commented 1 year ago

Don't know if this is HL7 dotnetcore issue or NHAPI

milkshakeuk commented 1 year ago

@manosg80 I've never seen that technique for creating segments before, have you tried newing up a MSH segment instead?

I'm not saying it's not an issue just never seen it done that way before.

Maybe this will help. https://saravanansubramanian.com/hl72xnhapicreatemessage/

https://github.com/nHapiNET/nHapi/blob/a43d8d9a36e27d06c75b070b93b7141b389870df/tests/NHapi.Base.NUnit/Model/AbstractSegmentTests.cs

manosg80 commented 1 year ago

Yes, actually using the MSH Segment was how I bypassed the issue. I had found this approach in a couple of tutorials with a more 'loose' approach as to what MSH fields should be present. I guess the '\' character is used for delimiting and hence can't exist in a field - at least that's what I think.

milkshakeuk commented 1 year ago

@manosg80 The code samples provided seem to be from HL7 dotnetcore not nhapi.

manosg80 commented 1 year ago

You are right, hence my previous comment that I might be knocking the wrong door. Apologies!

From: Jake Aitchison @.> Sent: Wednesday, February 15, 2023 22:14 PM To: nHapiNET/nHapi @.> Cc: manosg80 @.>; Mention @.> Subject: Re: [nHapiNET/nHapi] Exception adding an escaped string as field to Segment (Issue #414)

@manosg80 https://github.com/manosg80 The code samples provided seem to be from HL7 dotnetcore not nhapi.

— Reply to this email directly, view it on GitHub https://github.com/nHapiNET/nHapi/issues/414#issuecomment-1431970056 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHXXZ5SCSVAS45SGVELMLWXU2JFANCNFSM6AAAAAAU5GTB7M . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ABCHXX5RT73N2FNE3S3NUCLWXU2JFA5CNFSM6AAAAAAU5GTB7OWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSVLIQQQ.gif Message ID: @. @.> >

milkshakeuk commented 1 year ago

@manosg80 as this is not an nhapi issue can you close this?

manosg80 commented 1 year ago

Done.

From: Jake Aitchison @.> Sent: Thursday, February 16, 2023 1:46 PM To: nHapiNET/nHapi @.> Cc: manosg80 @.>; Mention @.> Subject: Re: [nHapiNET/nHapi] Exception adding an escaped string as field to Segment (Issue #414)

@manosg80 https://github.com/manosg80 as this is not an nhapi issue can you close this?

— Reply to this email directly, view it on GitHub https://github.com/nHapiNET/nHapi/issues/414#issuecomment-1432961971 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHXX665HJPYQIEUCJQJQ3WXYHQBANCNFSM6AAAAAAU5GTB7M . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ABCHXX3HGXOEELKK4ZJ2KQTWXYHQBA5CNFSM6AAAAAAU5GTB7OWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSVNFB3G.gif Message ID: @. @.> >