web stats
Specific filtering - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-18-2016, 08:23 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 60
mhaase is on a distinguished road
Default Specific filtering

I am using the following code to filter anything in the array of "facID" if it's present in "pid31" or "pid181". Upon testing it out, I altered the message to something that is not present in the array and the message is still filtered.

for each(seg in msg..PID)
{
var pid31 = seg['PID.3']['PID.3.1'].toString();
var pid181 = seg['PID.18']['PID.18.1'].toString();
var facID = ["MC", "CV", "ML", "LV"];

for (var i = 0, len = facID.length; i < len; ++i)
{
if ((pid31.indexOf(facID[i]) != -1) || (pid181.indexOf(facID[i]) != -1))
{
return false;
break ;
}

if(i==len-1) return true;

}
}

Any help on this would be greatly appreciated!
Reply With Quote
  #2  
Old 03-18-2016, 08:42 AM
jackwhaines jackwhaines is online now
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 179
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

It seems to be working for me, depending on the message. If you aren't sure why it's not working, try adding some debugging and check the log. Add this inside your for loop:

Code:
logger.info("i: "+i+" len: "+len+" pid31index: "+pid31.indexOf(facID[i])+" pid181index: "+pid181.indexOf(facID[i]));
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #3  
Old 03-18-2016, 09:09 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 60
mhaase is on a distinguished road
Default

Here is the log output.
Attached Images
File Type: jpg 3-18-2016 12-08-40 PM.jpg (49.2 KB, 5 views)
Reply With Quote
  #4  
Old 03-18-2016, 09:14 AM
jackwhaines jackwhaines is online now
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 179
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Put it here:

Code:
for each(seg in msg..PID)
{
var pid31 = seg['PID.3']['PID.3.1'].toString();
var pid181 = seg['PID.18']['PID.18.1'].toString();
var facID = ["MC", "CV", "ML", "LV"];

for (var i = 0, len = facID.length; i < len; ++i)
{
logger.info("i: "+i+" len: "+len+" pid31index: "+pid31.indexOf(facID[i])+" pid181index: "+pid181.indexOf(facID[i]));

if ((pid31.indexOf(facID[i]) != -1) || (pid181.indexOf(facID[i]) != -1))
{
return false;
break ;
}

if(i==len-1) return true;

}
}
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #5  
Old 03-18-2016, 09:16 AM
jackwhaines jackwhaines is online now
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 179
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

When I send this: PID|1||MC|. It filters.

When I send this: PID|1||LP0000002238||. It sends.

Is that what you want?
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #6  
Old 03-18-2016, 09:39 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 60
mhaase is on a distinguished road
Default

Quote:
Originally Posted by jackwhaines View Post
When I send this: PID|1||MC|. It filters.

When I send this: PID|1||LP0000002238||. It sends.

Is that what you want?
Yes, so kind of like:

If it contains 'MC0000019' then filter
If it contains 'XX0000019' then allow
Reply With Quote
  #7  
Old 03-18-2016, 09:42 AM
jackwhaines jackwhaines is online now
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 179
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

That seems to be working on my installation.
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #8  
Old 03-18-2016, 10:44 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 60
mhaase is on a distinguished road
Default

What version of Mirth are you using? I ran the code in a web page with the same values of 'MC0000019' and 'XX000019' set in a variable and they reflected either true or false. Frustrating!
Reply With Quote
  #9  
Old 03-18-2016, 10:52 AM
jackwhaines jackwhaines is online now
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 179
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

3.3.2
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #10  
Old 03-18-2016, 11:37 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 60
mhaase is on a distinguished road
Default

I tried it on that same version and no luck. Time to move on (again) !
Reply With Quote
Reply

Tags
array, filtering, javascript

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 07:17 AM.


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