Parse MSA segment using Terser #415
-
Description:Hi, im using Does anyone have any ideas on how to parse this segment? Error message
Heres my message
And a code fragment
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @jorge-zapata-medstone I can't replicate, I have created a dotnet fiddle showing it working here. using System;
using NHapi.Base.Parser;
using NHapi.Base.Util;
var newline = '\r';
// adding new line into the string on linux, not needed on windows
var message = $"""
MSH|^~\&|RAMSOFT|SENDING FACILITY|RAMSOFT|RECEIVING FACILITY|20101223202939-0400||ACK|101|P|2.5||||||||{newLine}
MSA|AA|104|Request was Successfully processed{newLine}
""";
var pipeParser = new PipeParser();
var parsed = pipeParser.Parse(message);
var terser = new Terser(parsed);
Console.WriteLine($"MSH.1: {terser.Get("/MSA-1")}");
Console.WriteLine($"MSH.2: {terser.Get("/MSA-2")}");
Console.WriteLine($"MSH.3: {terser.Get("/MSA-3")}"); I suspect it could be your message has the wrong line endings. In the HL7 specification, the end of each segment (line) should end with a carriage return i.e. |
Beta Was this translation helpful? Give feedback.
Hi @jorge-zapata-medstone I can't replicate, I have created a dotnet fiddle showing it working here.