Daily using/supporting

Get Firefox browser!
Get Thunderbird!
Get Opera browser!
Get The Gimp!
Get Inkscape!
Get LibreOffice!
Get Videolan!
Get Linux!
Get Mandriva!
Get Joomla!
Hacker Emblem

Archives

Which topics would you like us to cover more?

Latest comments

Latest tweets

about 2 days ago Using REDIPS.drag to add drag and drop to your .Net webapplication #li #dib0 http://t.co/n8zY3s7d
about 8 days ago http://t.co/cknQcDbo #Kindle
about 16 days ago Freedom isn't the ability to choose what to do or say, but the ability to choose what not to do or say #freedom
12 Apr 2012 Force the use of a networking adapter using C# #li #dib0 http://t.co/ZTJOPzOz
9 Apr 2012 Mandriva 2010.2 and USB devices in Virtualbox http://t.co/fwq9gbHB
9 Apr 2012 Execute a http request to you own site with PHP http://t.co/DIvWPrpd
Home Architecture, security and coding Implementing MLLP in C#
Implementing MLLP in C#
Written by Division by Zero   
Saturday, 13 February 2010 10:15

The MLLP (Minimal Lower Layer Protocol) protocol, which most HL7 communications use, is quite easy to implement in C#. Here's an example of how it can be done. The following code snippet is another way to "pack" and "unpack" MLLP messages. This needs to be done just after receiving and before sending a message over a TCP socket.

/// 
 /// This helper class supports the Minimum Low Layer Protocol
 /// 
 public abstract class MLLPHelper
 {
 #region Private constants
 private const int MLLP_START_CHARACTER = 11; // HEX 0B
 private const int MLLP_FIRST_END_CHARACTER = 28; // HEX 1C
 private const int MLLP_LAST_END_CHARACTER = 13; // HEX 0D
 #endregion

 #region Public static methods
 /// 
 /// Validate MLLP message
 /// 
 ///
 
Stringbuilder containing the message
 public static void StripMLLPContainer(StringBuilder sb)
 {
 // Strip the message of the MLLP container characters
 sb.Remove(0, 1);
 sb.Remove(sb.Length - 2, 2);
 }

 /// 
 /// Validate the MLLP message containing the HL7 message
 /// 
 ///
Message
 /// true if valid
 public static bool ValidateMLLPMessage(StringBuilder sb)
 {
 bool result = false;

 if (sb.Length > 3)
 {
 if (((int)sb[0] == MLLP_START_CHARACTER))
 {
 if (((int)sb[sb.Length - 2] == MLLP_FIRST_END_CHARACTER) && ((int)sb[sb.Length - 1] == MLLP_LAST_END_CHARACTER))
 result = true;
 }
 }

 return result;
 }

 /// 
 /// Create a MLLP message
 /// 
 ///
Original message
 /// MLLP message
 public static string CreateMLLPMessage(string p)
 {
 StringBuilder sb = new StringBuilder(p);
 sb.Insert(0, (char)MLLP_START_CHARACTER);
 sb.Append((char)MLLP_FIRST_END_CHARACTER);
 sb.Append((char)MLLP_LAST_END_CHARACTER);

 return sb.ToString();
 }

 /// 
 /// Test if the character equals the start message character
 /// 
 ///
Character to test
 /// True if matches
 public static bool IsStartCharacter(char start)
 {
 return (start == MLLP_START_CHARACTER);
 }
 #endregion
 }
 
 
 

Comments  

 
0 # Mayura 2012-05-07 16:12
I have used SSL stream to secure the MLLP transaction. Can you point me to any documentation to show how to set up the client and server certificates for the same?
Reply | Reply with quote | Quote
 
 
0 # Bas 2012-05-08 08:08
Hi Mayura,

I'm not sure I understand your question correctly. Do you want to use SSL as a client or a server? Do you use .Net?

If so, maybe these two posts will help you. They show how to use a server certiciate and a client certificate. In the comments (see the code examples) is shortly explained how to install/import a certificate in order to let the software work.

Here's the post on certificates on a server:
dib0.nl/.../...

here's the post on client-side certificates:
dib0.nl/.../...
Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh

I'm feeling so happy today. I think I'll call in sick. - Loesje


© 2009 - 2012, Division by Zero

Template based on the empire template by joomlashack 

Valid XHTML 1.0 Strict  Valid CSS!  Creative Commons License
This work by Division by Zero is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.