Removing a segment from an outgoing message

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Removing a segment from an outgoing message

  • Creator
    Topic
  • #48791
    Ariba Jones
    Participant

      I am trying to remove a segment from an outgoing message because the receiving system does not recognize this segment.

    Viewing 5 reply threads
    • Author
      Replies
      • #59682
        Russ Ross
        Participant

          Without getting into what your specific issue is, just let me say that the testing tool is great but will not always duplicate what the actual interface will do.

          The first thing to try is to recycle the process that is using the modified Xlate.

          Just changing the xlate will not pick up the change in a running interface, but it will pick up the change in the testing tool.

          Here is an outbound TPS proc I’ve been using with success for years to strip out undesired segments headed outbound.

          For example if you wanted to strip out the segments PV1, NK1, OBX

          then supply the following arguments

          {SEGMENTS PV1NK1OBX}

          Here is the code fo

          tps_remove_segment.tcl

          Code:

          ######################################################################
          # Name:     tps_remove_segment
          #
          # Author:   Chris Hale
          #
          # Date:    
          # 1999.03.10 Chris Hale
          #          – wrote intitial version          
          #
          # 1999.05.24 Russ Ross
          #          – fixed to not have memory leaks when creating new message
          #
          # Purpose:  Removes a segment(s) within a message.
          # UPoC type:   tps
          # Args:  tps keyedlist containing the following keys:
          #        MODE    run mode (”start”, “run” or “time”)
          #        MSGID   message handle
          #        ARGS    user-supplied arguments:
          #                 SEGMENTS – Segments that you wish to have removed.
          #           The segments should be passed with no
          #           spaces.  This allows you to delete as many
          #           segments as you like.
          #           EXAMPLE:
          #              {SEGMENTS PV1NK1OBX}
          #
          # Returns: tps disposition list:
          #    CONTINUE – original message will be overwritten
          #               with new messages that has the specified
          #               segments removed

          proc tps_remove_segment { args } {
            keylget args MODE mode                 ;# Fetch mode
            keylget args ARGS.SEGMENTS segments

            set dispList {}            ;# Nothing to return

            switch -exact — $mode {
           
               start {
                  return “”
               }

               run {
                  # ‘run’ mode always has a MSGID; fetch and process it
                  keylget args MSGID mh

                  # Initialize variables
                  set segname_list {}
                  set index1 0
                  set index2 2
                  set count 1
                  set new_msg {}

                  # Determine number of segments that you want to have eliminated
                  # and put them in list format
                  set arg_length [clength $segments]
                  set num_segments [expr $arg_length/3]
                  while {$count <= $num_segments} {            lappend segname_list [crange $segments $index1 $index2]            incr count            incr index1 3            incr index2 3         }         # echo REMOVING SEGMENTS ($segname_list)         # Retrieve the message and create a new message that         # contains only the segments that are wanted.         set msg [msgget $mh]         set seg_list [split $msg r]         foreach item $seg_list {            if {[cequal $item {}]} continue            set seg_id [crange $item 0 2]            set found_list [intersect $segname_list $seg_id]            if {[cequal $found_list {}]} {               append new_msg $item r            }         }                 msgset $mh $new_msg         lappend dispList "CONTINUE $mh"      }      time {         # Timer-based processing         # N.B.: there may or may not be a MSGID key in args      }        shutdown {            # Doing some clean-up work        }      default {         error "Unknown mode '$mode' in tps_remove_segment"      }   }    return $dispList }

          With what I know today, I would probably remove the segments that are undesired from the outbound HL7 variant.  This works well for my work now that I typically choose to do a field by field copy instead of bulk copies.

          Of course bulk copy versus field by field copy is another topic altogether and can be controversial.

          The code above is much quicker and easier to implement and might be your preference.

          Russ Ross
          RussRoss318@gmail.com

        • #59683
          Anonymous
          Participant

            Best is to change the variant (if its any possible on the outbound side) to make the segment optional and donot map that segment in your translate.  It should work.

            This way you are really affecting anything.

            Hari

          • #59684
            Anonymous
            Participant

              I mean NOT affecting anything.

            • #59685
              Ariba Jones
              Participant

                Thanks, Russ.  I will try this and see what happens.

              • #59686
                Ariba Jones
                Participant

                  Thanks, Hari.

                  I will see if what Russ has suggested will work.  If not, I will look into your suggestion.

                  The only thing is I need to map the segment in my xlate because I need to pull some values from that segment and put in another segment.  The segment is optional also.  It’s a Z segment coming from Star.

                • #59687
                  Pete Gilbert
                  Participant

                    You should also refer your vendor to 2.6.2 of the standard, which reads:

                    2.6.2 Rules for the recipient

                    The following rules apply to receiving HL7 messages and converting their contents to data values:

                    a) ignore segments, fields, components, subcomponents, and extra repetitions of a field that are present but were not expected.

                    b) treat segments that were expected but are not present as consisting entirely of fields that are not present.

                    c) treat fields and components that are expected but were not included in a segment as not present

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