Announcement

Collapse
No announcement yet.

Combine multiple OBX fields into one by removing carets ^

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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!

  • #2
    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;
    }

    Comment

    Working...
    X