· Dec 11, 2020

HL7 2.4 ADT messages (MLLP) to JSON format?

Is there anyone who has experience in translating HL7 2.4 ADT messages (MLLP) to JSON format? We are going to push ADT messages to Salesforce. However, salesforce does not support MLLP. All advice on this is welcome. Thanks a lot!

Product version: Caché 2018.1
Discussion (2)0
Log in or sign up to continue

Hi Rob,

This discussion I had with Mary George a couple of weeks ago might help:

Here the issue is accepting HL7 messages encoded as JSON; you are trying to the reverse.

Basically, first, you would have to save your HL7 data to the correct EnsLib.HL7.Message object (in this case the message type is ADT). This Object has several useful Properties and Methods that would allow you to get the number of Segments in the message and also get a segment Object by index. You can loop over your segments and extract the data from each segment. 

Once you have the data in the Properties of the object, there are two ways to continue:

1) If you were on IRIS, your custom object could also extend %JSON.Adaptor. The data from the message that you stored in Properties could then be exported to a JSON string by calling yourObject.%JSONExport(). However, this option is not available in Cache product line.

2) The Cache product line has support for Dynamic Objects. These are JSON-like objects that cannot be passed in methods or in Ensemble messages directly - you would need to serialize them into a String or a Character Stream (but they would appear as JSON).

Here is the link to the documentation on JSON:

(Because this is for IRIS is also includes a chapter on JSON Adaptors).

For example, in the same loop where you process your message, you could create a Dynamic Object for each Segment Field and use fieldObject.%Set("PID:"_i, valueOfPID:i) where i is the field number.

At the very end, where you have your complex Message Object you would 

Do msgDynamicObject.%ToJSON() - that will serialize the object to JSON String which you can then assign to a Property of an HttpRequest and post it to the Saleforce API. (I would create a separate Business Operation for that and use EnsLib.HTTP.OutboundAdapter). You would then need to process their JSON Response by doing

Set responseObject = {}.%FromJSON(HttpResponse.Data)

I hope this helps. Unfortunately, there is no easy way to do this.