mirthedi

How can I work with ASAPv4 messages in Mirth


If I have an ASAPv4 message (example spec) for reporting to state prescription drug monitoring programs, how can I read and write the message using NextGen Connect / Mirth?


Solution

  • ASAPv4 is very close to standard EDI/X12. If we ignore escape characters added in the later version of the standard, which it seems like most people do, then you can use the EDI serializer and some preprocessing to read and write ASAPv4.

    To receive an ASAPv4 message, select following in the source properties:

    To send an ASAPv4 message, select the following destination properties:

    var props = SerializerFactory.getDefaultSerializationProperties('EDI/X12');
    props.put('segmentDelimiter', '\\');
    tmp = String(SerializerFactory.getSerializer('EDI/X12', null, props).fromXML(msg)).replace(/\\/, '\\\\');