BizTalk HL7 Error: Failure executing BTAHL72XSendPipeline: Error details: "Body schema is missing"

Recently, I was working on an issue, in which we were trying to construct a multi-part HL7 message.

An HL7 message, generally consist of 3 segments:

  1. MSHSegments
  2. BodySegments
  3. ZSegments

We were calling the HL7 receive pipeline, from within the orchestration, using the following call:

Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(ReceicvePipelineType),input message)

We were successfully able to receive the messages and create the XML corresponding to all the 3 segments.
But when we tried to construct the multi –part message using the XMLs we were getting the error:
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'ODH.BTBiDirectional.Orchestrations.ProcessImmunizationHistory(7b3aa024-98a5-3af2-00e0-1eb55a9c888f)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.

InstanceId: 184c71e3-2a8d-4989-8dba-a032fffb4e7c
Shape name: ConstructMessage_1
ShapeId: 905a6fe1-58c1-4ab3-9791-1d44faa16bee
Exception thrown from: segment 5, progress 10
Inner exception: There was a failure executing pipeline "ODH.BTBiDirectional.Orchestrations.HL7TargetRSPSendPipeline". Error details: "Body schema is missing".  

We were constructing the multi part message as follows:

Multipartmsg.MSHSegment = MSHSegmentXML;
Multipartmsg.BodySegment = BodySegmentXML;
Multipartmsg.ZSegment = ZSegmentXML;

The reason we get the above error is due to the fact that message type property for multi-part message is not available in the context of the message. To overcome this problem you also need
to copy the context value from incoming message to multi-part message in the assignment shape while creating the multi-part message. You can use the following expression in the assignment shape to copy the context:

HL7MultipartMessage(*)=InputMsgForHl7BodyPart(*);

Also make sure that you set the MessageEncoding value for the newly formed HL7 message as well:

HL7MultipartMessage(BTAHL7Schemas.MessageEncoding) = 65001;

Once this being done, you can call the Send Pipeline from the orchestration and the message will get constructed successfully.

Hope this helps !!!

Written by
Rasika Chaudhary

Reviewed by
Chirag Pavecha

Microsoft India GTSC