Wednesday, September 05, 2007

Open-source .NET HL7 Parser

I recently spent some time searching for a good open-source .NET HL7 parser. The pickings were pretty slim, and the best option appears to be NHapi--which is a fairly new port of the popular Hapi Java HL7 parser. I had to dig surprising deep into the search results to find NHapi, and though the code seems solid, the project is not extremely active. Another big weakness is the complete lack of API documentation and code samples. You can figure out the essentials from the Hapi Javadoc and sample code, but that's a bit of a pain so I've generated MS Help API docs for each HL7 version supported by NHapi. They are available in a single zip file here (80MB).


atilla acar said...

Great work,
Can nHapi really works? I am trying to develop something with Hapi but it have some problems... Maybe I should pass nHapi before It is too late

AT said...

It works for the basics. We're still in pre-production evaluation and prototyping with it, so I can't tell you much more than that. You should post to the sourceforge forum if you have a particular scenario you want to ask about.

sam_gamegie said...

how do you run the chm files ?
I can't open then...

AT said...

If you don't have the MS Compiled Help viewer installed (unlikely) you need to install it. Otherwise it's likely a security restriction related to a Windows XP security update. Try this workaround.

Anonymous said...

How are the files compressed? WinXP is not able to unzip them.

AT said...

They are compressed with WinZip.

Anonymous said...

Thanks, I had tried with an earlier version of Winzip. Nice work on the documentation. Do you know why ADT_A04 and ADT_A08 classes are missing from versions 2.4 and 2.5?

AT said...

Those classes are missing from the documentation because they are missing from the compiled assemblies. I'm not sure why the classes themselves are missing.

Anonymous said...

Hi all, does anybody know how to create a TBR_R08 message? How to specify the RDT segment?

You can email me at:


Anonymous said...

Hi Ashley, this is Anwar from India, a software programmer by profession and currently working on R&D on healthcare & IT. During my digging on healthcare knowledge I found that HL7 plays major role in Healthcare, and for that nHAPI is helpful for parsing messages from HL7 to xml and xml to HL7.

During the search in Google i found this blog, which may really help me in my project.

I also read your profile and its really interesting.

Hope I will be an active member of this blog for knowledge gaining and sharing.

Anwar Shaik

AT said...

Thanks Anwar!

Vineeth said...

Hi ashley,
this is vineeth from india, we make our software as HL7 compactible. we are using nHapi API for message parsing.

so for this project i need your help.


Anonymous said...

I'm new to this, but when I try to create a PID.PatientNameGivenName = "Testing" I get a compile error since it is readonly. What am I doing wrong? Using .Net 2.0.


AT said...

anonymous, you should post your question to the NHapi discussion forum on source forge:

Anonymous said...

Thanks for your great work!
I use nHapi toolkit for compiling,it helps me deeply.
And it can save me a lot of time.
Thank you for sharing your documentation!

AT said...

You're welcome, Anonymous!

Anonymous said...

I'm a s/w engg working for a health care organization.I'm very new to HL7 protocol.I have few questions can you please answer.
Here is that....

1st of let me describe i 'm going to do:-

I want to develop a client software which will communicate with the LIS server (through TCP/IP)and i need to get the HL7 data and parse it and store it into my local database(May be MS access).Then i may have to show it to the user using my UI.

Note:- My application is going to be a VC++/MFC application.

Now my question is :-

1.How the NHapi can help me to fulfill my above describe question.
2.Can i use NHapi source code (as it is open source)to parse the information.I mean to say ...can i use it as HL7 to .Xml parser
3.If yes,where is the source code available.

i tried to download it from :-

But it is having some problem.i don't know why its not downloading...

N.B. :- pls note that my application is going to be a MFC application with VS2005

Please give response.

AT said...

@anonymous - If you're having trouble downloading or questions about the NHapi project I suggest you contact the project administrators.

Shikari Shambu said...

Do you have any sample programs using NHapi. The stuff in NHapi Quickstart does not seem to work

using NHapi.Base.Model;
using NHapi.Base.Parser;
using NHapi.Base;
using NHapi.Model.V23;
using NHapi.Model.V23.Message;
using NHapi.Model.V23.Segment;

string message =

PipeParser parser = new PipeParser();

//GET an error here.
Error 1 No overload for method 'parse' takes '1' arguments
IMessage m = parser.parse(message);

QRY_R02 qryR02 = m as QRY_R02;

AT said...

@Shikari Shambu: I suggest you post a question to the NHapi forums. I generated the docs here and did some early prototyping, but my company ended up using a different HL7 parser so I am not an NHapi expert by any means.

Anonymous said...

Hi Ashley,
Would you mind sharing with us why you went with another parser, and possibly which parser that was?
Thank you!

AT said...

@Gene: We chose a different parser because the nHapi developers were unresponsive to email or questions on the SourceForge forums. The final selection was a commercial parser from a small company named KliniTek. I was only peripherally involved in the process so I can't tell you anything about the KliniTek parser.

Anonymous said...

Thanks for the quick and thoughtful reply!

scottw512 said...

I can't open this with WinZip 11.2. Is there another version I should try, or could you post an archive made with Windows Explorer? Thanks.

AT said...

@scott2512: The zip file is plain vanilla and was created with WinZip 11.1. It has been downloaded hundreds of times over 2 years. Are you sure you didn't just get a corrupted or incomplete download?

ForMyAfrica said...

thank you so much mister Ashley,
Im karim from morocco and that help me so much to design my application.
But I have a big problem to getting DataBase of HL7 messaging it's not a open source. only the HL7 company buy it with 1100$ sure that I don't have it, so can help me ? this is my email thanks with best regards

AT said...

@karim: Sorry I can't help you with the HL7 database.

Unknown said...

thank u mister ashley Im sorry im just a student i can't buy this stupide database with all this money wherever ur nHapi is very interestin but i can't understand it without the dba so im beginnin to design my appli without referin to urs have a nice chance ;)

ForMyAfrica said...

But im steel workin for my africa (karim_GINFO) ;)

Anonymous said...


Are you available for contract side work with NHAPI and C#?

AT said...

@anonymous: I do some consulting and contracting work. Please send an email to the address on my profile if you are interested in discussing a particular project.

Kevin said...

Thanks. Just starting to investigate nHapi, and every little bit of info helps.

gaurav said...

Guys...Use Mirth software...or code fro of the best in health care domain. we are using this in our project.

michael said...

@Shikari Shambu: Try "parser.Parse" with uppercase "P" it's an error in the quickstart guide.

@ForMyAfrica: You don't need the database to make Nhapi work. Just to build classes for later versions of the standard, e.g. 2.6+

Anonymous said...

Hi Ashley,

i wants to use nHAPI for Audiometry data..this data is coming from NOAH system in the forms of i want to know which segment must be used to such data...and how should be its structure...

please help me...


Header photo courtesy of: / CC BY-NC 2.0