web stats
Filter - Javascript - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2016, 11:20 PM
Thoughts_Shared Thoughts_Shared is offline
OBX.2 Kenobi
 
Join Date: Dec 2016
Posts: 58
Thoughts_Shared is on a distinguished road
Default Filter - Javascript

I am using the below javascript to validate the message structure:
MSH EVN PID PV1 [PD1] [{ROL}]

But after PD1, I am not able to get it right. Any help is really appreciated.

var index = 0;
var insGroupIndex = 0;

for each (seg in msg.children()) {
var segName = seg.name().toString();

if (index == 0 && segName != 'MSH' || index == 1 && segName != 'EVN' || index == 2 && segName != 'PID' || index == 3 && segName != 'PV1') {
return false;
} else if (index > 3 ) {
if (insGroupIndex == 0 && segName != 'PD1')
return false;
if (segName != 'PD1')
insGroupIndex = 0;
if (insGroupIndex == 0 && segName != 'ROL')
return false;
insGroupIndex = (insGroupIndex + 1) % 3;
}

index++;
}

return true;
Reply With Quote
  #2  
Old 12-13-2016, 05:43 AM
Thoughts_Shared Thoughts_Shared is offline
OBX.2 Kenobi
 
Join Date: Dec 2016
Posts: 58
Thoughts_Shared is on a distinguished road
Default

Using the below code I am able to validate MSH EVN PID PV1 [PD1] or MSH EVN PID PV1 [ROL]. But still not able to validate MSH EVN PID PV1 [PD1] [{ROL}]

var index = 0;
var GroupIndex = 0;
var rGroupIndex = 0;

for each (seg in msg.children()) {
var segName = seg.name().toString();
if (index == 0 && segName != 'MSH' || index == 1 && segName != 'EVN' || index == 2 && segName != 'PID' || index == 3 && segName != 'PV1') {
return false;
} else if (index > 3 && index < msg.children().length() - 1) {
if (GroupIndex == 0 && segName != 'PD1' || rGroupIndex == 0 && segName != 'ROL')
GroupIndex++;
return false;
}
index++;
}
return true;

How do I validate a message for the format MSH EVN PID PV1 [PD1] [{ROL}]
Reply With Quote
Reply

Tags
filter, javascript, thoughts_shared, validation

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 04:21 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation