HL7MessageEncoder

Class Name: HL7MessageEncoder

Scope: Public - Unrestricted

Factory Creation: Yes - SQLSchemaAPIKey.NewEncoder() method

 

Used for parsing HL7 messages. You will notice when working with the API that most of the classes and methods that deal with HL7 message data directly will have an optional parameter of type HL7MessageEncoder named preferredEncoder. In the world 99% of the time you can ignore this parameter and let the method or class just do it's thing, and everything will work swimmingly. Until it doesn't.

 

Public PropertiesPublic Properties (ReadOnly)

 

Public PropertiesPublic Properties (Read / Write)

 

MethodsPublic Methods

 

Implementation: When the object is created all of the Read/Write properties are set to their ANSI default values. You can then change them if needed to instruct the HL7 message parser on any non-ANSI idiosyncrasies your HL7 messages might contain.

 


 

Exception Handling: Follows the Common Exceptions Interface.

 


Discussion

The HL7 standards are really quite strict, they say "Here's how it's going to be, unless you decide amongst yourselves to do it differently". Our parsing engine can parse any properly formed HL7 2.x message with very little need for help from the developer. There are a couple of exceptions though and you must at least be aware of them to work with this API.

 

You must know:

1.What the BOM and EOM characters are (if your HL7 message strings contain them) and whether or not they are the ANSI standard characters. If not you need to create a "customized" encoder object to tell the API how to behave. In the SQL Schema Engine, these values are warehoused in the HL7 Vendor Definition. In the API you use the HL7MessageEncoder class.

2.What the SEGMENT delimiter (sometimes called the SOM) is and whether or not it is the ANSI standard (A carriage return or Ascii character 13 or Hex[0D]).

 

Programming note about #2. We try as hard as we can to make the API forgiving, so our parser will forgive the most common mistakes people make with the SEGMENT delimiter which is the general "messing up" of Carriage Returns CR, Line Feeds LF, and Carriage Return-Line Feeds CRLF.

 

The scenario is simple, the HL7 message contains the ANSI standard Carriage Return, then somebody decides to look at the message in some less than great text editor, they change it, save it, and voila the file now contains a CRLF instead a CR.

 

IF your HL7MessageEncoder has the SegmentDelimiter property set to the ANSI standard CR, then your messages can also have EITHER LF or CRLF SegmentDelimiters as well and they will parse just fine.

 

Example: using a non-standard SegmentDelimiter value.

 

C#

 

           SQLSchemaAPIKey MyKey = new SQLSchemaAPIKey("Valid Key or File");

           HL7MessageEncoder var = new HL7MessageEncoder();

          //  Or

           var = MyKey.NewEncoder();

          //I have a trading partner that uses the TAB character

          //as the Segment Delimiter. Hey, we've seen it.

           var.SegmentDelimiter = MyKey.Utils.FromAsciiHexString("09");

          string sHL7 = "<one of the offending messages>";

          if(!MyKey.TestHL7Message(sHL7,var))

           {

              //It's bad

               Console.WriteLine(MyKey.LastError);

           }

          else

           {

              //It's good

               Console.WriteLine("Huzzah!!");

           }

 

 

 

 

 

© 2015 HermeTech International
(a Division of TransWorld Scribes)