Online Help - Region 1: [CORE HL7 API Basic] |
Object: HL7Message
NOTE: No public entry point. Created only through a Controller object.

HL7 Messsage Architecture
Best Practice Methods for Dealing with Control Characters:
The object provides you with all of the individual properties and methods for dealing with Control Characters. For best practices we recommend that you use only the 3 methods listed in this first table to query or set the Control Characters by using the HL7EncodingCharacters object class.
Best Practice Methods |
|
|
|
Method |
Return Value |
ControlCharactersAreAnsi() |
bool - Will be true if all control characters are set to their ANSI Default Values |
MyEncodingCharacters() |
Returns a HL7EncodingCharacters object with the current control character values for the HL7Message object |
ResetControlCharactersToAnsi() |
void - Resets all of the control characters to their ANSI Default Values |
SetAllControlCharacters() |
void - takes a HL7EncodingCharacters object as parameter 1 and sets all of the individual control character values |
Property Name |
Data Type |
ExceptionHandling |
Uses the Standard Exceptions Interface |
EncodingToUse |
System.Text.Encoding - Set to System.Encoding.Default by default. This property is reserved for use by the TCP/IP Libraries |
ForceEndingFieldDelimiter |
bool - Default is false. If true the parser will insure that every segment ends with a Field Delimiter |
ForceFinalSOM |
bool - Default is true. If true the parser will insure there is a final SOM (SegmentDelimiter) after the LAST segment in the message |
IsLoaded |
bool - Will be true if the object has any HL7Segments loaded. |
MSHSegment |
HL7Segment (read only) - If not IsLoaded will return null, else will be the HL7Segment object for the MSH segment of the message ( same as calling GetSegment(1) ) |
ParentController |
Controller Object - Reference to the Parent object that created the HL7Message |
RawValue |
string (read only) - Only applies to messages LOADED, if you CREATE the message will be empty. Will contain the raw string used to INITIALLY fill the object ( Set Value or call LoadHL7Message() ) |
SegmentsCount |
int (read only) - Will be the number of segments contained in the HL7 Message |
Tag |
|
TrimEmptyFields |
bool - Default is true. If true the parsing engine will remove all EMPTY trailing HL7 Fields from each segment |
Utilities |
COREUtilities object - Reference the online help for Region 3 Help CORE HL7 Dialogs |
Value |
string - Get returns the HL7 Message loaded as a string. You can Set this value also by passing in a fully formed HL7 message string (same as calling LoadHL7Message() method) |
EnvelopedValue |
string (read only) - Will return the Value wrapped in the BOM and EOM values |
Method |
Return Value |
ExceptionHandling |
Uses the Standard Exceptions Interface |
AddSegment(string value) |
HL7Segment - Appends a HL7Segment onto the end of message. value cannot be empty and can either contain just a 3 character segment name (Example: "PID") or value can contain a string with a fully formed HL7Segment string value (Example: "PID|1|123345|54321^License|etc. etc.") |
AllSegments() |
HL7Segment[] Returns a one dimensional array of all HL7Segments in the message. |
Clear() |
void - Clears the objects Value |
CloneAllSegments() |
HL7Segment[] Returns a one dimensional array with all HL7Segments (Disconnected) in the message. |
CreateHL7Segment(string value) |
HL7Segment (Disconnected) - Returns a disconnected HL7Segment object. value cannot be empty and can either contain just a 3 character segment name (Example: "PID") or value can contain a string with a fully formed HL7Segment string value (Example: "PID|1|123345|54321^License|etc. etc.") |
GetSegment(int index) |
HL7Segment object . index is 1 based so GetSegment(1) returns the MSH Segment. If index less than 1 or greater than SegmentsCount returns null. |
GetFirstSegmentNamed(string segmentName) |
HL7Segment object . Returns first segment named segmentName in the message or null if NOT SegmentExists(segmentName). |
GetSegmentsNamed(string segmentName) |
List<HL7Segment> Returns a generic List of segments in the message named segmentName if no segments match will return an empty List. |
InsertSegmentAt(int index, HL7Segment value) |
HL7Segment object Returns the inserted connected HL7Segment object or null if an error occurs. index is the 1 based ordinal position to insert the segment. You cannot use 1 as index UNLESS the HL7Message object is empty AND the value is a MSH segment. |
LoadHL7Message(string value) |
bool - value must be a fully formed HL7 message containing AT LEAST the MSH segment. If returns false check LastException. |
LoadHL7Message(HL7Segment[] segments) |
bool - segments will be a one dimensional array of disconnected HL7Segment objects. If segments is empty it's the same as calling the Clear() method. The first element of segments MUST be a MSH segment. |
MSHLogValues(string delimiter = ",") |
string - If IsLoaded returns a delimited string (delimiter supplied in Parameter 1 default is a comma) of property values from the MSHSegment. In order the values will be: MessageControlID, MessageType, MessageEvent, SendingApplication, SendingFacility, ReceivingApplication, ReceivingFacility, MessageDate, TestProdFlag, and HL7Version |
RemoveSegment(int index) |
HL7Segment (Disconnected) - Removes the HL7Segment object from the HL7Message at 1 based ordinal position index, or returns null if an error occurs. index cannot be 1 as you cannot remove the MSH segment from a message, so index must be > 1 and <= SegmentsCount. |
Save(string fileName, bool includeIPEnvelope = false, bool overWriteFile = false) |
bool - Saves the Value property value to fileName. If includeIPEnvelope is true the value is wrapped in BOM and EOM envelope. If fileName does not exist it will be created. If overWriteFile is false the Value is APPENDED to fileName, if overWriteFile is true then fileName will be overwritten if it exists. Value cannot be empty. If returns false check LastException for error. |
SaveRawValue(string fileName, bool includeIPEnvelope = false, bool overWriteFile = false) |
bool - Saves the RawValue property value to fileName. If includeIPEnvelope is true the value is wrapped in BOM and EOM envelope. If fileName does not exist it will be created. If overWriteFile is false the RawValue is APPENDED to fileName, if overWriteFile is true then fileName will be overwritten if it exists. RawValue cannot be empty. If returns false check LastException for error. |
SegmentCount(string segmentName = "") |
int - Returns the number of segments in the message named segmentName, passing an empty segmentName will return SegmentsCount property value. |
SegmentExists(string segmentName) |
bool - Indicates whether a segment named segmentName exists in the message (IE SegmentCount(segmentName) > 0) |