web stats
~ in OBX - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2012, 06:08 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 224
rav is on a distinguished road
Default ~ in OBX

Hi ,

How to handle ~ in OBX segment related to javascript.

I have the following code. Any help is appreciated.


var text = new String();



for each(obx in msg.OBX) {

if(obx['OBX.5'].length > 1) {
for each (val in obx['OBX.5']) {
text = text + val['OBX.5.1'].toString() + '\n';
}
} else {
text = text + obx['OBX.5']['OBX.5.1'].toString() + "\n";
}

}


return text ;

}
Reply With Quote
  #2  
Old 11-12-2012, 07:48 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,483
narupley is on a distinguished road
Default

To iterate through repeating fields using E4X, you must first check Parse Field Repetitions in the HL7 v2.x data type properties. Then you can do this:

Code:
var text = '';
msg.OBX['OBX.5'].(function(){text+=(new XML(this))['OBX.5.1'].toString()}());
Or:

Code:
var text = '';
for each (obx in msg.OBX)
	for each (obsVal in obx['OBX.5'])
		text += obsVal['OBX.5.1'].toString();
__________________
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 11-12-2012, 09:14 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 224
rav is on a distinguished road
Default

Hey that worked .. Thank you..
Reply With Quote
  #4  
Old 12-04-2012, 11:36 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 224
rav is on a distinguished road
Default

I have to parser ~ and create new OBX for each tilda..Any suggestions please
Reply With Quote
  #5  
Old 12-04-2012, 12:05 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,483
narupley is on a distinguished road
Default

Quote:
Originally Posted by rav View Post
I have to parser ~ and create new OBX for each tilda..Any suggestions please
Using the above suggestion, you can iterate through your OBX.5 nodes, and for each iteration, either use one of the createSegment functions, or use the E4X appendChild method to add nodes manually to either msg or tmp.
__________________
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
  #6  
Old 12-04-2012, 12:15 PM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 224
rav is on a distinguished road
Default

Thanks for the reply.

I used the following code and I don't see any new OBX getting created

var text='';
for each (obx in msg.OBX)
for each (obsVal in obx['OBX.5'])
text += obsVal['OBX.5.1'].toString();
if(text=='~'){
createSegment('obx')
}

Can you let me know where I went wrong..
Reply With Quote
  #7  
Old 12-04-2012, 02:45 PM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 224
rav is on a distinguished road
Default

Does anyone has a sample code or an existing thread where I can look into..I have to parse ~ and create new OBX's..Thanks in advance..
Reply With Quote
  #8  
Old 12-04-2012, 03:50 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,483
narupley is on a distinguished road
Default

Quote:
Originally Posted by rav View Post
Does anyone has a sample code or an existing thread where I can look into..I have to parse ~ and create new OBX's..Thanks in advance..
Here's an example (make sure to have Parse Field Repetitions enabled):

Code:
for each (obx in msg.OBX) {
	for (var i = obx['OBX.5'].length()-1; i > 0; i--) {
		var newObx = obx.copy();
		newObx['OBX.5'] = obx['OBX.5'][i].copy();
		msg.insertChildAfter(obx,newObx);
	}
	obx['OBX.5'] = obx['OBX.5'][0];
}
__________________
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:00 PM.


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