Adding the Batch Seg to a VXU msg

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Adding the Batch Seg to a VXU msg

  • Creator
    Topic
  • #54899
    Don Anderson
    Participant

      I keep erroring on the “set newSegmentList [lreplace $newSegment1 $segmentList $newSegment2]”

      Does anyone see something obvious?

      set msg [msgget $mh]

                     set segmentList [split $msg r]

      echo segmentList $segmentList

                     set newSegment1 [lindex BHS|^~&|]

                     set newSegment2 [lindex BTS|1|]          

                     

      echo seg1 $newSegment1

      echo seg2 $newSegment2          

                     set newSegmentList [lreplace $newSegment1 $segmentList $newSegment2]    ;# replace with the updated segments  This is where it FAILS

      echo newList $newSegmentList

                     set newMsg [join $newSegmentList r]                                 ;# Put msg back together with cr

                     msgset $mh $newMsg                                                                                  ;# set mh

    Viewing 12 reply threads
    • Author
      Replies
      • #83356
        Brandon Grudt
        Participant

          There are quite a few issues with that.  What exactly are you trying to do?

        • #83357
          Brandon Grudt
          Participant

            I guess I can help by defining the things that I see which are immediately wrong.

            When you set those two variables, the lindex format is way off.

          • #83358
            Don Anderson
            Participant

              Basically the VXU (immunizations) message type for Boston HIE requires that it be inclosed with the Batch Segments even though no batches are sent and they don’t use it. But the State requires it. Its not a HL7 standard so I just need to add the BHS and BTS segments to the msg

              Does that help

            • #83359
              Brandon Grudt
              Participant

                So you want to insert a generic batch header and trailer, but you’re going to be sending these messages individually?

              • #83360
                Don Anderson
                Participant

                  Yes

                • #83361
                  Don Anderson
                  Participant

                    I had done already done what you sugested and got

                    m^PWIM^^^Left Arm^M^MBTS|1| ( Double c/r between the last seg and the BTS Seg

                  • #83362
                    Levy Lazarre
                    Participant

                      Don,

                      I believe that an easier way to accomplish this is by simple string concatenation – no need for list commands:

                      Code:


                      set header “BHS|^~&|r”
                      set trailer “BTS|1|r”

                      set newMsg $header${msg}$trailer

                      Give this a try and see what happens.

                      Of course, this assumes that msg ends with a carriage return as it should. If not, you can always prepend it to the trailer:

                      set trailer “rBTS|1|r”

                    • #83363
                      Don Anderson
                      Participant

                        That didn’t work so good, it just wrote a r in the msg instead of the ^M

                      • #83364
                        Levy Lazarre
                        Participant

                          This shouldn’t happen. I am not sure what editor you are using. Replace the “r” in the string by whatever technique is necessary to insert a carriage return in the text. In vi for example, it would be Ctrl-V followed by Ctrl-M

                          Have you tried the Cloverleaf editor?

                        • #83365
                          Don Anderson
                          Participant

                            Thats what Im using, Let me try again. Thanks

                          • #83366
                            Don Anderson
                            Participant

                              I tried again and got the same results

                              BHS|^~&|^MMSH|^~&||12

                              msg segments

                              Left Arm^M^MBTS|1|vxu_bos{FILESET {{OBFILE v

                              Double c/r and no c/r after BTS Seg

                              When I run it throu the testing tool it looks good except the msg segments are all between { }

                            • #83367
                              Robert Milfajt
                              Participant

                                This should work.

                                Code:

                                set header “BHS|^~&|”
                                set trailer “BTS|1|”
                                set newMsg [join [list $header ${msg} $trailer] r]

                                Hope this helps,

                                Robert Milfajt
                                Northwestern Medicine
                                Chicago, IL

                              • #83368
                                Don Anderson
                                Participant

                                  Ok , I’ll try it and let you know

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