web stats
Combine multiple OBX fields into one by removing carets ^ - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2014, 12:08 PM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 31
Jaypell22 is on a distinguished road
Default Combine multiple OBX fields into one by removing carets ^

I have done some digging and havent come accross anything that works specific to this.

I need to remove the carets and make each field show up in OBX.5.1 separated by a comma. There is no telling how many total fields there will be or how many OBX lines will contain the carets so I need to check all lines.

I am looking to take an obx line shown here:

OBX|24|TX|ID^Chief complaint:||C/O SOB, COUGH, CP^14.3 MCI 133XE^4.9 MCI 99MTC MAA^PTINJECTED: RT WRIST IV

And make it look like this:

OBX|24|TX|ID^Chief complaint:||C/O SOB, COUGH, CP,14.3 MCI 133XE,4.9 MCI 99MTC MAA,PTINJECTED: RT WRIST IV




Thank you!
Reply With Quote
  #2  
Old 05-28-2014, 12:38 PM
aquillen aquillen is offline
OBX.1 Kenobi
 
Join Date: Dec 2010
Posts: 30
aquillen is on a distinguished road
Default

narupley's example (different post) of parsing children (at the carets) into tildes led me to this solution:
Code:
/*Replace OBX.5 carets (sub field delimiters) with commas - art quillen 5/28/2014
 * code.toString within a child: extracts one subsegment/field between delimiters
 * Note that delimiters include pipe (|) and caret (^). Adds a comma at end of each
 * extract to effectively replace the delimiters with commas. Note that the last
 * delimiter (|) becomes a comma too, so finish up by dropping last comma via regex
 */

for each (obx in msg.OBX) {
	var codeGroup = '';
	for each (code in obx['OBX.5'].children()) codeGroup += code.toString()+",";
	obx['OBX.5'] = codeGroup.replace(/,$/, "");
}
narupley provided this:

Code:
for each (ft1 in msg.FT1) {
	var codeGroup = <></>;
	for each (code in ft1['FT1.26'].children())
		codeGroup += <FT1.26><FT1.26.1>{code.toString()}</FT1.26.1></FT1.26>;
	ft1['FT1.26'] = codeGroup;
}
Reply With Quote
Reply

Tags
caret, combine, obx, separate

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 03:56 AM.


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