In Mirth Connect, Is there anyway to validate sequence number MSH:13 whether it is valid number in sequence with current sequence number or not ?

For e.g. if Previously processed message sequence no MSH:13 is 102.

Then current incoming message sequence no MSH:13 should be 103.

If it is not 103 then validator should reject the message.

1

There are 1 best solutions below

2
On

I assume your messages are processing sequentially. In Mirth Connect that means a single-threaded source connector and a single-threaded destination connector (or a destination connector with a thread-assignment-variable set to your message sequence id).

You can set a globalChannelMap variable with your sequence number. globalChannelMap.put('lastSeqNo', msg['MSH']['MSH.13']) . Then you can simply compare your current sequence number to globalChannelMap.get('lastSeqNo') and decide to reject or filter the message.

Be aware of:

  • javascript types (you want to compare numbers not strings)
  • initializing 'lastSeqNo' to zero if it is not already set (as when a channel is deployed with "clear global channel map" selected) OR ensuring that your comparison handles the case when 'lastSeqNo' is null
  • what to do if the sender resets its own sequence number. Will this value increase forever or might the sender some day reset it to zero?