Announcement

Collapse
No announcement yet.

Replacing characters in the OBX segments

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

  • Replacing characters in the OBX segments

    I have this code to replace the values below when they are in the OBX segment. I am seeing the error below.

    Starting data - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10^3/mcL^x10^3/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE
    Expected data result - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10E3/mcL^x10E3/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE

    Starting data - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10^6/mcL^x10^6/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE
    Expected data result - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10E6/mcL^x10E6/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE

    tmp.replace('^x10^3', '^x10E3');
    tmp.replace('x10^6', 'x10E6');

    SOURCE CODE:
    4584:
    4585: tmp['MSH']['MSH.5']['MSH.5.1'] = 'IHIE';
    4586:
    4587: tmp.replace('^x10^3', '^x10E3');
    4588: tmp.replace('x10^6', 'x10E6');
    4589: if ('xml' === typeof msg) {
    4590: if (msg.hasSimpleContent()) {
    4591: msg = msg.toXMLString();
    4592: }
    4593: } else if ('undefined' !== typeof msg && msg !== null) {
    LINE NUMBER: 4589
    DETAILS: TypeError: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.



  • #2
    tmp is an xml objects, not a string, and the replace method works differently to do xml node replacement rather than string replacement.

    Comment


    • #3
      You could use string methods in an attachment script, where the message is a string. Manipulating the message once it is parsed into an xml object is different - especially when the character you want to replace is a separator (^ = component separator).
      In your OBX.6 field you have 4 components: OBX.6.1=x10, OBX.6.2=3/mcL, OBX.6.3=x10, OBX.6.4=3/mcL
      I can only offer you a very very nasty hack:
      Code:
      for each (var seg in msg.children()) {[INDENT]if (seg.name().toString() == "OBX") {[/INDENT][INDENT=2]if(seg["OBX.6"]["OBX.6.1"].toString()=="x10") {[/INDENT][INDENT=3]var obx6=new XML("<OBX.6><OBX.6.1>" + seg["OBX.6"]["OBX.6.1"].toString() + "E" + seg["OBX.6"]["OBX.6.2"].toString() + "</OBX.6.1><OBX.6.2>" + seg["OBX.6"]["OBX.6.3"].toString() + "E" + seg["OBX.6"]["OBX.6.4"].toString() + "</OBX.6.2></OBX.6>");[/INDENT][INDENT=3]seg["OBX.6"]=obx6.copy();[/INDENT][INDENT=2]}[/INDENT][INDENT]}[/INDENT]
       }
      This makes a new OBX.6 if OBX.6.1="x10"

      Comment


      • #4
        I hadn't noticed that the component separator was part of the replacement string. schillert is correct that it makes the problem even more difficult in a transformer. String replacement is probably the way to go. I think the most appropriate place to do this would be in the pre-processor script. Should be a simple 1-liner:
        Code:
        return message.replace(/x10\^(\d)/g, 'x10E$1');

        Comment


        • #5
          What are my options to do this in a transformer since I have multiple destinations on this thread?

          Comment


          • #6
            Originally posted by math1964 View Post
            What are my options to do this in a transformer since I have multiple destinations on this thread?
            Once it is fixed, it is fixed, what do you mean?
            Diridium Technologies, Inc.
            https://diridium.com

            Comment

            Working...
            X