Announcement

Collapse
No announcement yet.

ODT segment

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

  • ODT segment

    I have the code below that creates the ODT when OBR12 is >0. What change is needed to not have the ODT segment created when OBR12.1 is blank?

    if (obr12.length > 0)
    createSegmentAfter('ODT', msg['ODS'])
    {
    var ODT1 = <ODT/>
    ODT1['ODT.1']['ODT.1.1'] = msg ['OBR'][0]['OBR.12']['OBR.12.1'].toString();
    ODT1['ODT.2']['ODT.2.1'] = 'ALL';
    ODT1['ODT.2']['ODT.2.2'] = 'ALL';
    if (NTEseg1 > 0)
    msg.ODS[NTEseg1 - 1] += ODT1;
    else
    msg.ODS[thisODSNum - 1] += ODT1;
    }

  • #2
    Check the OBR12.1 value with these statements also.

    PHP Code:
    if (typeof(obr12) != "undefined" || obr12 != null || obr12 != "") {


    Last edited by obsessio; 04-08-2020, 01:16 PM.

    Comment


    • #3
      Check for OBR-12 array and OBR-12.1 string length.

      Code:
      If (msg.OBR['OBR.12'].length() > 0 && msg.OBR['OBR.12'][0]['OBR.12.1'].toString().length != 0) 
      {
            createSegmentAfter('ODT', msg['ODS'])
      
      }
      Last edited by jkrebs; 04-09-2020, 07:15 PM.

      Comment


      • #4
        Originally posted by jkrebs View Post
        Check for OBR-12 array and OBR-12.1 string length.

        Code:
        If (msg.OBR['OBR.12'].length() > 0 && msg.OBR['OBR.12']['OBR.12.1'].toString().length != 0) 
        {
              createSegmentAfter('ODT', msg['ODS'])
        
        }
        The first check isn't really necessary. msg.OBR['OBR.12']['OBR.12.1'].toString() will return an empty string even if msg.OBR['OBR.12'].length() is equal to zero. This is something unique to xml objects. It's actually an XMLList, and not an array. You can request child elements from an empty XMLList, and it will still return another empty XMLList rather than returning undefined like a regular javascript object would if you tried to access a nonexistent property.

        Comment


        • #5
          The first check isn't really necessary. msg.OBR['OBR.12']['OBR.12.1'].toString() will return an empty string even if msg.OBR['OBR.12'].length() is equal to zero. This is something unique to xml objects. It's actually an XMLList, and not an array. You can request child elements from an empty XMLList, and it will still return another empty XMLList rather than returning undefined like a regular javascript object would if you tried to access a nonexistent property.
          Thanks for the clarification. Will use that logic going forward.
          Last edited by jkrebs; 04-09-2020, 07:12 PM.

          Comment

          Working...
          X