Appending string to all OBX

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Appending string to all OBX

  • Creator
    Topic
  • #51581
    Mark Perschbacher
    Participant

      As part of this huge data conversion project I have been hammering on, I need to append x0a to OBX 5.  I have been playing around with what seems like the standard method for altering and rebuilding messages.

      foreach segment $obx {

          set field [split $segment $fieldSep]

      set afield [lindex $field 5]

      append field ” x0a”

      set sfield [join $field r]

      #set final

        #set field [lappend $field 5 5 $cr]

        #set field [join $field $fieldSep]

        set subf [lindex $sfield 5]

        set obx6 [lreplace $subf 0 end $obxlist2]

        set sfield [lreplace $sfield 0 end $obx6]

                       set segment [join $field $fieldSep]

                    }

        This approach seems to work fine for substituting values for a given subfield, but not for appending a string to all iteration of that subfield.  If there was a way to use a combination of lappend and lreplace, I think it would work.  Any ideas?

    Viewing 6 reply threads
    • Author
      Replies
      • #70841
        Tom Rioux
        Participant

          Mark,

          If I’m reading your code correctly, your “append field” command is appending the “x0a” to the end of the segment list of fields.   Didn’t you say you wanted it tagged on to the end of the OBX.5 field specifically?

          If so, then you would want to maybe do a concat of the $afield and the “x0a”.

          Hope this helps…

          Tom Rioux

        • #70842
          Mark Perschbacher
          Participant

            I’m getting really close on this.  I tried the concat, but it didn’t write the x0a, it put in the cr.  Here is the code I have so far.

            set obx [lrange [lregexp $segmentList {^OBX}] 0 end]

            set cr “x0a”

            foreach segment $obx {

                set field [split $segment $fieldSep]

            set afield [lindex $field 5]

            append afield ” $cr “

            set field [lreplace $field 5 5 $afield]

            set segment [join $field $fieldSep]

            set segmentList [lrange $segmentList 0 4]

            lappend segmentList “$segment”

            echo $segmentList

                                       }

            What I am getting out in tester for segmentList is the iterating message from MSH to OBR with the OBX values from $afield appended starting with OBX 1 down the iterate.  I have tried ever combination I can think of to get all the OBX’s to append to the first iteration , but no luck.

            {OBR|1||SS10 Report|||201002090000||||||||||||||||F||61080^Chatterley^Scott} {OBX|1|TX|SS10-1620$rpt^^99DHT|| x0a ||||||F}

            {OBR|1||SS10 Report|||201002090000||||||||||||||F||61080^Chatterley^Scott} {OBX|2|TX|SS10-1620$rpt^^99DHT||DATE COLLECTED:2/9/2010 00:00 x0a ||||||F}

            {OBR|1||SS10 Report|||201002090000|||||||||||||||F||61080^Chatterley^Scott} {OBX|3|TX|SS10-1620$rpt^^99DHT||SPECIMEN: x0a ||||||F}

          • #70843
            Tom Rioux
            Participant

              Post your code in your iteration from the xlate.  It appears you may not have the iteration variables set up correctly.  

              Just a hunch…

              Tom Rioux

            • #70844
              Mark Perschbacher
              Participant

                This is a standalone proc, long story.  I just use the word iteration since it seems to descirbe what is happening.

              • #70845
                Tom Rioux
                Participant

                  If I now understand correctly, you want the contents of all of the OBX.5 fields to now be in the first OBX and the rest of the OBX”s can be trashed.  If so, try this to see if it works.   I haven’t tested it so…hope it helps…Tom

                  set obx [lrange [lregexp $segmentList {^OBX}] 0 end]

                  set cr “x0a”

                  set seg “”

                  foreach segment $obx {

                    set field [split $segment $fieldSep]

                    set afield [lindex $field 5]

                    append afield ” $cr “

                    if {[string equal $seg “”]} {

                        set seg $segment

                    }

                  }

                  set obxfields [split $seg $fieldSep]

                  set field [lreplace $obxfields 5 5 $afield]

                  set segment [join $field $fieldSep]

                  set segmentList [lrange $segmentList 0 4]

                  lappend segmentList “$segment”

                  echo $segmentList

                • #70846
                  Mark Perschbacher
                  Participant

                    Thomas, thanks for your reply.  I was able to get it to work by appending segment “$segment”  The issue I am running into now is that I am getting a different output from tester and running it through the engine.  Back to the drawing board.

                  • #70847
                    Tom Rioux
                    Participant

                      Sounds elementary I know, but make sure you bounced the process before attempting to run the message through the engine.

                      Tom

                  Viewing 6 reply threads
                  • The forum ‘Cloverleaf’ is closed to new topics and replies.