Class HL7Parser
- Namespace
- EDIParser
- Assembly
- EDIParser.dll
Parses HL7 messages using delimiter values defined in the MSH segment.
public sealed class HL7Parser : Parser, IComponent, IDisposable
- Inheritance
-
HL7Parser
- Implements
- Inherited Members
Remarks
The parser is initialized with standard HL7 delimiters:
carriage return for segments, | for fields, ^ for components,
~ for repetitions, \ for escapes, and & for
subcomponents.
By default, delimiter values are read from the MSH segment before parsing.
Constructors
HL7Parser()
Initializes a new instance of the HL7Parser class using the standard HL7 delimiters.
public HL7Parser()
Properties
CheckMSHSeparator
Gets or sets a value indicating whether delimiter characters should be read from the MSH segment before parsing.
public bool CheckMSHSeparator { get; set; }
Property Value
- bool
true to detect separators from MSH-1 and MSH-2; otherwise, false to use the currently configured delimiters.
EscapeChar
Gets or sets the HL7 escape character.
public string EscapeChar { get; set; }
Property Value
SegmentSeparator
Gets or sets the delimiter used to separate HL7 segments.
public override string SegmentSeparator { get; set; }
Property Value
Remarks
The parser may automatically switch between carriage return and carriage-return/line-feed separators based on the source message.
Methods
ParseMsg(string)
Parses an HL7 message and populates the parser object model.
public override void ParseMsg(string msg)
Parameters
msgstringThe HL7 message to parse.
Remarks
When CheckMSHSeparator is enabled, the field, component, repetition, escape, and subcomponent delimiters are read from the initial MSH segment.
The MSH field delimiter and encoding characters are temporarily replaced with parser tokens so that MSH can be represented consistently within the normal field object model.
The parser detects whether the source message uses carriage return or carriage-return/line-feed segment separators.
Exceptions
- ArgumentNullException
Thrown when
msgis null.- ArgumentException
Thrown when the message is too short to contain the MSH delimiter definition.
- Exception
Thrown when the configured segment separator cannot be found in the message.