ASTM E1394 Message Parsing

Theron W. Genaux

21-February-2025

 

This project demonstrates generically parsing ASTM E1394 (a.k.a LIS2) messages. It is a prototype demonstrating a method to parse any ASTM E1394 (ASTM) message and return key/value pairs containing all the information in the message. These key/value pairs can recreate an equivalent ASTM message.

In 2015, I started working with vendors and customers to help them interface with my company's new family of instruments, which used the ASTM E1394 message format. I wondered how LIS and middleware vendors could adapt and connect with so many instruments as each instrument manufacturer developed its message format based on the ASTM E1394 standard.

I had already seen some code that reads and writes ASTM messages on the web and proprietary. I always thought that they were error-prone and overly complex. I wondered how reading, writing, and processing ASTM messaging could be generalized to adapt to all the variations I've seen. I also wanted to make it less error-prone.

I played around mentally with different ideas for a while until I realized that an ASTM record is, in essence, a recursive data structure with one recursion per separator. ASTM records have three separators: field, Repeat-Field, and Components. Because they only have three delimiters, they are limited to only three levels of recursion.

HL7 version 2 (pipe-delimited) messages use segment, field, component, and sub-component delimiters, which have four separators and four levels of recursion. This code can be used with version 2 (pipe-delimited) messages.

The following output is from a program developed to explore two ideas: generically reading and writing ASTM messages and using bidirectional maps (Translation Map). ASTM messages are parsed into position/value pairs, where the key identifies the position of a value in a record. These position/value pairs are then mapped to token key/value pairs, where the key determines the value type. The program supports round-tripping, so the extracted content from one message can recreate the equivalent original message. The original translation map can map the token pairs to position pairs that can be used to recreate an equivalent ASTM message.

Input message:

Parse massage into record Position:Value pairs:

 

A bidirectional translation map is used to remap the Position:Value pairs into Key:Value pairs and to remap the Key:ValuePosition:Value pairs back into Position:Value pairs.

An Order record like this:

Is parsed into Position:Value pairs:

It can be remapped into Key:Value pairs using a bi-directional translation map:

Remapping to Key:Value pairs:

 

I used a bidirectional translation map to remap the message Position:Value pairs into Key:Value pairs.

Here we list the extracted message Key:Value pairs:

Recreate the message by first converting Key:Value pairs into record Position:Value pairs:

 

Export Position/Value pairs into an ASTM message: