Archives
- ► 2013 (8)
- ► 2012 (35)
- ► 2011 (157)
- ► 2010 (174)
- ► 2009 (12)
Which topics would you like us to cover more?
Latest comments
-
How to create an application s...
Maybe some of the other posts will help you too: d...
By Bas -
How to create an application s...
Hi Joe! Glad this post and the discussion is helpf...
By Bas -
How to create an application s...
Ok, I think I'm getting my head around it now... t...
By Joe -
How to create an application s...
this is probably the most helpful discussion ive c...
By Joe -
How to shutdown your server wi...
IT didn't work with centos 6
By David -
How to reset you Kindle 3, eve...
Thank you! I was in the middle of listening to a b...
By Madison Woods -
Using a client certificate wit...
Thanks Bas
By betsy -
Using a client certificate wit...
Hi Betsy, No there isn't. Java runs in a virtual m...
By Bas
Latest tweets
about 4 days ago
Noscript and fritz.box #dib0 http://t.co/zxHEedNf9Q
about 10 days ago
Social engineering from India #dib0 http://t.co/ajjp43WkVS
about 19 days ago
@unwoman Got the kickstarter Uncovered Vol. 2 today! Thank you! I love it! http://t.co/x0Tzovtq8u
about 21 days ago
A query is running #dib0 http://t.co/cRZ8Dd3nVp
15 Apr 2013
Locally save attachments from Oulook using VBScript #dib0 http://t.co/l6RhWQsvFL
1 Apr 2013
Publishing Outlook calendar for use in Google calendar through http://t.co/sfh5eNxGXM #dib0 http://t.co/IzWNPlaqNA
21 Mar 2013
http://t.co/j3B0kSLGkM Really interesting article. The church of pirates. Gods preferential option for the poor in the broadest sense.
14 Mar 2013
Happy Pi-day! And this is what's wrong with it... funny, but true. http://t.co/A8GIB8fugC
14 Mar 2013
Hey guys @piwik ! Just looking at my site stats. I love the new page overlay feature. Well done! :-)
3 Mar 2013
Really funny! The Burning Hearts Revolution: How Sesame Street is Undermining Biblical Values http://t.co/z8XFk5P4d3
26 Feb 2013
Recursively check and correct mp3 files in Linux #dib0 http://t.co/U3nzOuWzWM
26 Feb 2013
Haha! Met zo'n antwoord een terechte reactie! http://t.co/NYXIb27aP5 via @snippers
20 Feb 2013
Create random password with C#, Java and PHP #dib0 http://t.co/WgF7DtcT
| nHapi example |
| Written by Division by Zero |
| Friday, 30 April 2010 14:22 |
|
A while ago I wrote a suggestion on how to write an application to support multiple version of HL7 using nHapi. After some questions I received, an example application seems to be helpful. My original post seems to be a little abstract. So here's the example solution I just hacked together. Enjoy! If you have any questions, let me know! |
I think, therefore I am. - R. Descartes














Comments
Thank you for your compliment!
Thanks again,
Division by Zero
Employing .Net dynamics, one can implement a factory without a naive switch implementation. For example:
IMessage message = parser.Parse(message);
dynamic o = Convert.ChangeType(mess age, message.GetType());
PL location = o.PV1.AssignedPatient Location;
The only disadvantage is that you lose compile-time checking, but this approach should drastically reduce boiler plate code.
Cheers,
Pete
Thank you for your comment. This way will absolutely shorten the code.
There are two reasons that I didn't use .Net dynamics. The first one is that it didn't yet exist at the time (I think... maybe it did and I didn't know about it at the time). The second one is that this code is an example. Statements like dynamic sure are code optimizations. On the other hand they make the code far less comprehensible for less experienced developers. In my opinion it is better to have more code that is better readable than to have less code that isn't.
Of course if an experienced developer would take this example. .Net dynamics will shorten the code and, therefore, make it easier to maintain.
Thanks,
Division by Zero
NHapi does support HL7 version 2.1. From where do you get the error? Maybe you could include the stacktrace of the error.
If you use the example solution I provided here to parse a 2.1 version message it will give you an error like this one. The solution is given as an example and support for other version must be added.
If you look at the file HL7VersionFacto ry.cs at line 16: there is a case statement that will check the HL7 version. You will see that only version 2.4 is added. You can add version 2.1 and add the parsing bit.
If you have any problems, please share the error with the stacktrace or bits of code where the error occures. Maybe I can help.
RSS feed for comments to this post