Parse MSA segment using Terser #415
Answered
by
milkshakeuk
jorge-zapata-medstone
asked this question in
Q&A
Description:Hi, im using Does anyone have any ideas on how to parse this segment? Error message Heres my message And a code fragment |
Answered by
milkshakeuk
Feb 18, 2023
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. |
1 reply
Answer selected by
jorge-zapata-medstone
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @jorge-zapata-medstone I can't replicate, I have created a dotnet fiddle showing it working here.