This was a fun problem to solve with the Translator, and as if often the case the solution is quite simple
This is what we need to do:
- Identify (partial) messages with continuations and save them to the database
- Identify the continuation messages and retrieve the initial message
- Stitch the messages together to create a complete HL7 message
Note: This example assumes that messages are broken into two parts, and will need to be adapted to handle more parts.
How It Works
The first step is to identify (partial) messages with continuations and save them to the database.
First we create the SQLite database and tables if they do not exist. Then we test for the existence of the DSC continuation segment and use the cont module to push the message into the database using the continuation ID as the primary key.
Save a continued message to the Database
Here is a screen shot:
Note: to ensure that the code works on any system the DB and VMD files do not specify a path and therefore default to using the Iguana install directory. You can customize this for your system by changing SQLITE_DB and VMD_FILE variables to something like
PushContinuation() function uses
cont.put() to save the message to the database:
cont.put() function inserts the message associated with that Continuation ID into the database, or replaces it if it already exists. If you are interested in in how this works you can look at the code for the module (it uses the SQL REPLACE keyword).
Retrieve a continued message from the Database
Now when we get the continuation message we simply retrieve the first message and concatenate the data together.
When we get a message with a continuation pointer in the MSH segment we do this:
- Fetch the original HL7 message from the database using the continuation pointer
- Extract the first part of the lab text from the OBX segment
- Strip off the ADD part of the lab text
- Concatenate it together with a space to the end part of the lab data
- Translate .br escape sequences to n
This formats the message in a nice human-readable format. Obviously, you can process the in other ways, whatever is suited to your needs.
Here is a screenshot:
By clicking on the return annotation of the
MergeText() routine we can see the full lab result in human-readable format:
And as you can see the continuation string “until cleared by this MD at follow-up.” has been appended.
We have shown you how the code to concatenate a two part message works, the next step is to add your own code to process the concatenated message. The sample code is available on the next page.
If you need to support messages with more than two parts you will need to modify the code. One way to do this would be to change the
FetchContinuation() function to recursively retrieve all the continuations for a message.
Please contact support at firstname.lastname@example.org if you need more help.