Announcement

Collapse

NextGen (Mirth) Connect 3.10.0 Released!

NextGen (Mirth) Connect 3.10.0 is now available as an appliance update and on our GitHub page. This release includes better SQL Server database support, security improvements through fixes and library updates, and improvements for the Advanced Clustering plugin with a focus on improving performance of many of the tasks that are carried out on a frequent interval. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Repeating OBX segments with null data

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

  • Repeating OBX segments with null data

    Using the attached sample message, with this JS in a destination transformer step:

    Code:
    var obxi = 0;
    
    while (msg['OBX']['OBX.1']['OBX.1.1'][obxi] != null) {
      logger.info(obxi + ' instance of OBX.5.1 = ' + msg['OBX']['OBX.5']['OBX.5.1'][obxi]);
    obxi++;
    }
    ....is resulting in this in the log:

    0 instance of OBX.5.1 = 279
    1 instance of OBX.5.1 = 265
    2 instance of OBX.5.1 = 41
    3 instance of OBX.5.1 = Test cancelled because triglycerides >250 mg/dL
    4 instance of OBX.5.1 = 15
    5 instance of OBX.5.1 = undefined

    The fourth instance of OBX.5.1 should be null, but we seem to be skipping to the next instance instead, leaving an "undefined" for the last instance. Any ideas what's causing this and how to fix it?

    sample_ORU_R01.txt (877 bytes)

  • #2
    Re:Repeating OBX segments with null data

    Try checking for string length > 0 also.

    Sample code:
    Code:
    var obxi = 0;
    var tempOBX = "";
    
    while (msg['OBX']['OBX.1']['OBX.1.1'][obxi] != null) {
      tempOBX = msg['OBX']['OBX.1']['OBX.1.1'][obxi].toString();
      if (tempOBX.length > 0) {
         logger.info(obxi + ' instance of OBX.5.1 = ' + msg['OBX']['OBX.5']['OBX.5.1'][obxi]);
      } 
    obxi++;
    }
    Hope it helps!

    Comment


    • #3
      Re:Repeating OBX segments with null data

      Checking for string length > 0 did not help, but putting the obxi variable in the right place made it work just right:

      Code:
      logger.info(obxi + ' instance of OBX.5.1 = ' + msg['OBX'][obxi]['OBX.5']['OBX.5.1']);

      Comment

      Working...
      X