web stats
Mirth Community - View Single Post - Combine multiple OBX fields into one by removing carets ^
View Single Post
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

narupley's example (different post) of parsing children (at the carets) into tildes led me to this solution:
/*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:

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