LSchuster.HL7MessageProcessor
1.0.5
See the version list below for details.
dotnet add package LSchuster.HL7MessageProcessor --version 1.0.5
NuGet\Install-Package LSchuster.HL7MessageProcessor -Version 1.0.5
<PackageReference Include="LSchuster.HL7MessageProcessor" Version="1.0.5" />
<PackageVersion Include="LSchuster.HL7MessageProcessor" Version="1.0.5" />
<PackageReference Include="LSchuster.HL7MessageProcessor" />
paket add LSchuster.HL7MessageProcessor --version 1.0.5
#r "nuget: LSchuster.HL7MessageProcessor, 1.0.5"
#:package LSchuster.HL7MessageProcessor@1.0.5
#addin nuget:?package=LSchuster.HL7MessageProcessor&version=1.0.5
#tool nuget:?package=LSchuster.HL7MessageProcessor&version=1.0.5
HL7 .Net Message Processor
LSCH.HL7MessageProcessor is a .NET library for parsing and working with HL7 v2.x messages. It provides structured access to message headers and values without mutating the input string, making it suitable for read-only inspection, validation, and routing scenarios.
Features
- ๐ Deep field access by segment name and component indices
- ๐งฉ Immutable
HL7ReadonlyMessagewrapper - โ HL7-compliant header parsing (MSH segment)
- ๐งช Tested with xUnit and FluentAssertions
- โ๏ธ Optimized for performance with
ReadOnlySpan<char>
Install via NuGet
dotnet add package LSchuster.HL7MessageProcessor
Or via NuGet Package Manager:
Install-Package LSchuster.HL7MessageProcessor
Quick Start
using LSCH.HL7MessageProcessor;
// Read the HL7 message from a file
var rawMessage = File.ReadAllText("some-message.hl7");
var hl7 = new HL7ReadonlyMessage(rawMessage);
// Access message header data
var sendingApp = hl7.Header.SendingApplication;
var messageDate = hl7.Header.ParsedDateTime;
// Read a specific field
string patientId = hl7.GetValue("PID", 3, 1); // Segment: PID, Field 3, Component 1
// Read a specific field from multiple segments
IReadOnlyList<string> values = hl7.GetValues("OBR", 4, 2); // Segment: OBR, Field 4, Component 2
// Check if the message is structurally valid
bool isValid = hl7.IsValid();
// Check if it's an ACK message
bool isAck = hl7.IsAcknowledgment();
Console.WriteLine($"Is ACK? {isAck}");
// Generate an acknowledgment
if (!isAck && isValid)
{
var ack = hl7.GenerateAcknowledgement(
switchSenderAndReceiver: true,
acknowledgmentCode: "CR", // "CA" for success, "AE"/"AR"/"CR"/"CE" for errors
errorMessage: "Missing required field: PID-5"
);
string ackRaw = ack.ToString();
Console.WriteLine("Generated ACK:\n" + ackRaw);
}
Testing
The library includes a dedicated xUnit test project that uses real HL7 sample messages. Tests verify structural parsing, header field correctness, and field access methods.
Run tests locally:
dotnet test
Project Structure
src/
HL7MessageProcessor/ # Library project
test/
HL7MessageProcessor.Tests/ # xUnit test project
โโโ TestData/ # Contains sample .hl7 files
License
This project is licensed under the MIT License.
Links
Author
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.