Base for HL7 v2 services provided by HL7Connect



HL7Connect.V2.Message CreateMessage();
   Create a blank HL7 message

HL7Connect.V2.Message CreateMessageForVersion(string version);
   Create a blank HL7 message and set the version

HL7Connect.V2.Message CreateMessageForEvent(string version, string event_, string msg);
   Create a blank HL7 message and set the version, event, and structure (MSH-9-1 and MSH-9-2)

HL7Connect.V2.Message CreateMessageFromStream(Stream stream);
   Read the stream as a v2 message. May be vertical bar or XML in any character encoding, with or without BOM. The entire stream will be read; it must start at the start of the message and end at the end of the message

HL7Connect.V2.Message Clone(HL7Connect.V2.Message message);
   Clone an HL7 message to a new instance that can be modified without altering the original instance

void SaveMessageToStream(HL7Connect.V2.Message message, Stream stream);
   Save the message to a stream using the default encoding (the format it was read from, the format of the message to which it is an answer - if it is, or vertical bar format)

void SaveMessageToStreamWithFormat(HL7Connect.V2.Message message, Stream stream, string format);
   Save the message to a stream using the specified format. Format is a series of tokens separated by spaces. The tokens may be one of the following:
  • XML
  • ER7 (for vertical bar)
  • [char-encoding] where character encoding is ANSI, UTF-8, UTF-16BE etc. Default is ANSI for ER7 and UTF-8 for XML
  • OptimisticMapping - when writing XML, how the segments are mapped against the segment structure. If this is not defined, then the list of segments must match the expected list. If this is not defined, then the mapping code will attempt to deal wit
  • AllowMappingToFail - If this is set, then if mapping fails, any remaining segments not mapped will be mapped into the root segment. If this is not set, and mapping fails, then an exception will be raised and encoding will fail. Relevent for XML
  • EscapeExtendedCharacters - When this is set the extended characters (non-ANSI) will automatically be escaped in ER7 format. Should only be used with character set ANSII
  • ExtraFieldDelimiter - for OACIS system that requires an extra Field Delimiter at the end of every segment
  • NoAddStructureName - whether to automatically encode the structure (if it can be determined by default it is added unless this option is set)
You can't specify logically incompatible options (such as XML and ER7)

string GetPatientId(HL7Connect.V2.Message message);
   The patient id of the message if it can be unambiguously determined. a null result may not indicate that a message does not contain an id, just that it cannot be determined with confidence without knowledge of specific interface busines rules. This function should only be used for messaging administration purposes (such as display in logs etc) and not when managing actual patient records

HL7Connect.Exchange.TransferredMessage CreateTransferredMessage();
   Create a transferred message ready for use with sending and/or receiving messages

void ExecuteScript(string script, string entryPoint, string language, string param, bool wantDebug, HL7Connect.V2.DataObject context);
   pass an HL7 v2 object to vbscript, javascript, COM, or OCL.

script: the name of a file containing the source, or the source itself entrypoint: the name of the procedure to run, or the coclass name for com language: the name of the language to use. will be inferred from the file extension of the script if there is one. wantDebug: when using windows script host context: the object on which the scripting will occur - either a message, segment, dataelement, or component

Note that the script can change the contents of the object passed to it. Any handles that the host retains to contents of the objects may be invalid after it executes (except for OCL, which cannot change the object)

1. Windows Script Host

If the language is "VBScript", "JScript", or any other language string the Windows Script Host recognises, or if the file extension is (".vbs, *.js, *.py, *.pl).

The script procedure is invoked with a single parameter which is an IExecuteHL7Event event. The kernel objects therwise available in when using scripts in HL7Connect will be null except for the WScript equivalent object.

The script engine is Windows Script Host, like the rest of HL7Connect. The want debug flag is passed through to the windows script host engine for whether to invoke the debugger or not.

2. COM

If the language is "COM", the script is ignored. The entry point is the coclass name of a registered class that implements the IHL7ConnectEventHandler interface (start mode is single threaded), which will be passed a IExecuteHL7Event.

3. OCL

if the language is "OCL" or he file extension is ".ocl", the ocl provided will be executed against the message. If any assertions in the ocl script fail, an exception will be raised containing the details

HL7Connect.V2.Message BuildByKScript(string script);
   Build an IHL7Message by executing a KScript. The KScript must build a valid v2.xml version of a message. The script may be either a filename or the KScript directly

© Kestral Computing P/L 2000 - 2003. HL7Connect v2.00-063 generated on 30-Nov 2015.
Keywords: HL7v2Manager, Clone, BuildByKScript, ExecuteScript, GetPatientId, CreateMessage, CreateMessageForEvent, CreateMessageForVersion, CreateMessageFromStream, CreateTransferredMessage, SaveMessageToStream, SaveMessageToStreamWithFormat, HL7Connect.Services.HL7V2Manager