web stats
Determine OBR.25 value based on the children OBX.11 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2013, 06:35 AM
LDHL7 LDHL7 is offline
Mirth Guru
 
Join Date: Apr 2011
Posts: 177
LDHL7 is on a distinguished road
Default Determine OBR.25 value based on the children OBX.11

I need to look at all of the OBX.11 field values for a given parent OBR segment to determine the OBR.25 value.

So, if I loop through the child OBX.11 of a given OBR, if any of them have a "P", I need to make OBR.25 = "P". If all of the OBX.11 values are "F", then the OBR.25 gets an "F".

I thought I had done similar logic for something in the past, but I'm drawing a blank!
Reply With Quote
  #2  
Old 10-18-2013, 09:52 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,115
narupley is on a distinguished road
Default

Quote:
Originally Posted by LDHL7 View Post
I need to look at all of the OBX.11 field values for a given parent OBR segment to determine the OBR.25 value.

So, if I loop through the child OBX.11 of a given OBR, if any of them have a "P", I need to make OBR.25 = "P". If all of the OBX.11 values are "F", then the OBR.25 gets an "F".

I thought I had done similar logic for something in the past, but I'm drawing a blank!
You can use getSegmentsAfter to do that.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR

Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 10-21-2013, 05:30 AM
LDHL7 LDHL7 is offline
Mirth Guru
 
Join Date: Apr 2011
Posts: 177
LDHL7 is on a distinguished road
Default

I'm familiar with that code template. So, I guess I would just use that to find the OBXs and if the obx.11 equates then change the OBR.25 value? This doesn't work because it will only make the determination based on the last OBX child of the OBR, unless I'm missing something

Code:
for each (obr in msg.OBR){
	for each (obx in getSegmentsAfter(msg,obr,'OBX')){
		if(obx['OBX.11']['OBX.11.1'] == 'P')
		{
		obr['OBR.25']['OBR.25.1'] = 'P'
		}
		else if(obx['OBX.11']['OBX.11.1'] == 'F')
		{
		obr['OBR.25']['OBR.25.1'] = 'F'
		}
	}
}

Last edited by LDHL7; 10-21-2013 at 05:37 AM.
Reply With Quote
  #4  
Old 10-21-2013, 09:08 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,115
narupley is on a distinguished road
Default

Code:
for each (obr in msg.OBR) {
	var prelim = false;
	var final = true;
	for each (obx in getSegmentsAfter(msg,obr,'OBX')) {
		if (obx['OBX.11']['OBX.11.1'].toString() == 'P')
			prelim = true;
		else if (obx['OBX.11']['OBX.11.1'].toString() != 'F')
			final = false;
	}

	if (prelim)
		obr['OBR.25']['OBR.25.1'] = 'P';
	else if (final)
		obr['OBR.25']['OBR.25.1'] = 'F';
}
__________________
Step 1: JAVA CACHE...DID YOU CLEAR

Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

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 -7. The time now is 08:20 PM.


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