Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Combine multiple OBX fields into one by removing carets ^ (http://www.mirthcorp.com/community/forums/showthread.php?t=10746)

Jaypell22 05-27-2014 12:08 PM

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!

aquillen 05-28-2014 12:38 PM

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;
}



All times are GMT -8. The time now is 07:50 AM.

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