1

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.

Mari
  • 23
  • 5
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 11 '22 at 13:19

1 Answers1

0

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?
Freiheit
  • 8,408
  • 6
  • 59
  • 101
  • You are right Freiheit. I'm validating with lastseqNo. Thank you for answering. The user also can reset the sequence no. Is there any provision to read it from user configuration based on a key value pair and and to updated the same in MC. How to do that I'm new to MirthConnect(MC). – Mari Mar 16 '22 at 07:40
  • I'm not sure I understand when the user would reset the sequence number. If a real human administrator needs to reset the number manually, you can just redeploy the channel with "clear global channel map" selected. If there are message conditions that would reset the sequence, then write that logic to update the globalChannelMap value. Can you edit your original post with some sample messages showing example sequence numbers and showing when those should reset? – Freiheit Mar 16 '22 at 12:51