Thanks to visit codestin.com
Credit goes to github.com

Skip to content

wokket/FastHL7

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast HL7 Library

CI Build NuGet version (FastHl7)

There are (at least) two other .Net HL7 libraries that are well known in the community:

  • NHapi is ridiculously fully featured, use it and love it if you want strongly typed spec compliant messages.
  • HL7-V2 has a nice design ethos and is much lighter than NHapi, but has many years of legacy code and forked history, interesting coding standards and netstandard2.0 back compat to worry about. As a previous contributor to this library you may see similarities :)

These are both fantastic libraries, with different trade-offs, and I've used both successfully in production in the past.

This library aims for the simplicity of HL7-V2, while being strictly modern .Net, and as lean as we can make it! It is not intended to be the one HL7 library to rule them all!

It is currently focused on reading messages, not building/writing them, and it makes no attempt to validate messages against the spec.

It aims provides a set of tools for your toolkit, rather than being a fully integrated all-in-one framework, and rewards sparse access to the message structure. If you need every single field in the message, one of the other libraries may be a better fit, or maybe not.

How fast is it?

There's a set of benchmarks in the Benchmarks directory, but the TL;DR is that it's very fast, and very low allocation:

To parse a fully featured message and query some data:

| Method       | Mean       | Ratio  | Gen0    | Gen1    | Allocated | Alloc Ratio |
|------------- |-----------:|-------:|--------:|--------:|----------:|------------:|
| FastHl7      |   1.620 us |   1.00 |  0.0153 |       - |     288 B |        1.00 |                                                                                                                                                                                                                                        
| Hl7V2        |  25.401 us |  15.68 |  7.4463 |  1.2817 |  128696 B |      446.86 |
| NHapi_Parser | 172.307 us | 106.38 | 29.2969 | 12.6953 |  518875 B |    1,801.65 |

As noted over there it's difficult to do a truly apples-apples comparisons of some features, but if you think a benchmark is unfair/misleading then please submit a PR to make it better!

Installation and Getting Started

Pretty simple:

  • Add a reference to the FastHl7 Nuget package

  • Create a message from a string (or other ReadOnlySpan<char>:

    • using FastHl7;
      var message = Message.Parse(hl7MessageString);
  • Query segments, fields etc:

    •   var patientFirstName = message.Query("PID.5.2");
  • There are helpers for date time conversions/de-escaping special chars:

    •   var dobText = message.Query("PID.7");
        var dobAsDate = dobText.AsDate();
    • var noteText = message.Query("NTE.3");
      var unescapedNote = noteText.Unescape();

Samples

There's an example of a high-performance MLLP listener (server) in the samples directory.

Things to do (in no particular order)

About

Performance-focused modern .Net Hl7 V2 toolkit

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages