Skip to main content

HL7 Batch Messages

HL7 Batch Messages

Ensemble supports nested child documents (batch formats) in HL7. Each of the child documents is an Ensemble virtual document in its own right. This section discusses the details, which are controlled by two settings. It includes the following sections:

Supported Batch Formats

Ensemble supports the following HL7 batch formats:

  • BHS MSH ... MSH ... BTS

    Ensemble recognizes BHS as a batch header segment, and BTS as a batch trailer segment. Within this container, Ensemble recognizes each MSH message header segment as the beginning of a child document.

  • FHS MSH ... MSH ... FTS

    Ensemble recognizes FHS as a batch header segment, and FTS as a batch trailer segment. Within this container, Ensemble recognizes each MSH message header segment as the beginning of a child document.

  • FHS BHS MSH ... MSH ... BTS BHS MSH ... MSH ... BTS FTS

    When FHS and BHS begin the message together, Ensemble recognizes FHS as the first-level parent document and each BHS as the beginning of a child document. BHS then becomes a second-level parent and the contents following each MSH segment become its child documents.

generated description: segment batch

Processing Incoming Batch Documents

HL7 business services have the Batch Handling configuration setting, which determines how to process incoming batch documents. The options are:

  • Whole Batch — Do not process child documents individually; accumulate and send the whole batch as one composite document.

  • Single-Session Batch — Forward all child documents in the batch together in one session; the session includes objects representing the batch headers and trailers. Single-Session Batch is the default if no Batch Handling value is specified.

  • Multi-Session Batch — Forward each child document in the batch in its own session, with a unique session ID.

  • Individual — Forward each child document in the batch in its own session; do not forward objects representing the batch headers and trailers.

In responding to received messages, the default behavior is to send an acknowledgment to the sender as a batch document that contains an ACK message for each child document. This works for most situations. However, HL7 business services also have a property, not exposed as a configuration setting, called NoBatchReply. Its default value is 0 (false), which provides the default behavior. If you edit your business service’s OnInit() method to include this statement:

Set ..NoBatchReply = 1

Then batch replies are inhibited; each individual message gets a separate unwrapped ACK. Alternatively, you could set the value by overriding the definition of the property in a subclass by including the following code:

 Property NoBatchReply As %Boolean [ InitialExpression = 1 ]; 

Sending Batch Messages

On the outgoing side, HL7 File and FTP business operations have the Auto Batch Parent Segs configuration setting. When Auto Batch Parent Segs is False (the default) the business operation outputs child documents, but does not output the batch headers and trailers. When Auto Batch Parent Segs is True, while outputting a message that has a batch parent, the business operation outputs the batch headers first, then the child documents, then follows up with the batch trailers when triggered by the final batch header message or by a file name change.

Batch Modes

The combination of Batch Handling and Auto Batch Parent Segs enables the following modes of operation for HL7 batch documents:

Batch Handling Auto Batch Parent Segs Results
Whole Batch (any) Business service sends only the parent document; all child documents are referenced to it but not sent individually. Operation outputs entire batch at one time when it receives the parent document.

Single-Session

or

Multi-Session

True Service sends each child document as it receives and parses it, followed by the parent document when all children have been sent. The business operation outputs parent headers when it receives the first child document, then finishes up with trailers when it receives the parent document object. Trailer segments automatically contain the correct child count values.

Single-Session

or

Multi-Session

False This results in double output: the business operation sends out each child document individually, followed by the parent document containing each child document (again).
Individual False Business service forwards each child document in the batch in its own session and does not forward objects representing the batch headers and trailers. On the outgoing side, the business operation does the same.

Custom Outbound Batch Handling

If you wish to add custom code to your routing process to handle batch documents specially on the output side, you can do so. The following are two possibilities:

  • Your routing process code creates new parent and child documents and links them, then sends each child to the business operation. The business operation must have Auto Batch Parent Segs set to True. The business operation outputs parent headers when it receives the first child document, then finishes up with trailers when it receives the parent document object. Trailer segments automatically contain the correct child count values.

  • Your routing process code creates new parent and child documents and links them, but sends only the parent object via the business operation.

FeedbackOpens in a new tab