OBX First Segment

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf OBX First Segment

  • Creator
    Topic
  • #50843
    Femina Jaffer
    Participant

    Hello Everyone,

    I am in need of assistance, please help me.

    I need to find an abnormal flag in any of the OBX segments (the flag is ‘*P”).  Once I find this in the message, I need to append ONLY the first OBX segment with an “ABN” at the end.  

    E.g OBX|1||||abasddkfdjkfjdkf|||ABN

    What is the best way to handle this.  

    Femina

Viewing 13 reply threads
  • Author
    Replies
    • #67727
      Jim Kosloskey
      Participant

      Femina,

      I am not sure there is sufficient information but I will give a start.

      If using an Xlate:

      1. Iterate over the OBX (probably a group dpending on Message structure).

      2. Inside the ITERATE use an IF Action to check the field in question for the ‘P’.

      3. Inside the above IF Action COPY the first OBX (zero in the group position – if this is a group repetition).

      4. COPY =ABN to the appropriate field in the first OBX.

      Now what is unclear –

      –  Do you want all of the inbound OBX segments to be repeated to the outpbound andONLY append ABN as a field to the first OBX?

      – Do you want only one OBX segment if any of the OBX segments have a ‘P’ in tha appropriate field?

      – What do you want if none of the segments has a ‘P’?

      email: jim.kosloskey@jim-kosloskey.com

    • #67728
      Femina Jaffer
      Participant

      Jim,

      Here are the answers to your questions:

      –  Do you want all of the inbound OBX segments to be repeated to the outpbound andONLY append ABN as a field to the first OBX?

      YES, this is correct.

      – Do you want only one OBX segment if any of the OBX segments have a ‘P’ in tha appropriate field?

      – What do you want if none of the segments has a ‘P’?

      Leave the message or segment alone.

      fj

    • #67729
      Jim Kosloskey
      Participant

      Femina,

      New logic…

      If using an Xlate:

      1. Iterate over the OBX (probably a group depending on Message structure).

      2. Outside of the IF Action, but inside the ITERATE – COPY all of the OBX fields for each repetition.

      3. Inside the ITERATE use an IF Action to check the field in question for the ‘P’.

      4. Inside the above IF Action COPY =ABN to the first OBX (zero in the group position – if this is a group repetition) in the appropriate field.

      email: jim.kosloskey@jim-kosloskey.com

    • #67730
      Femina Jaffer
      Participant

      Jim,

      Thanks Jim.  However, I will need to do this in TCL as the message coming in is in a UDM format.  We alread have code that converts to the ORU format.

    • #67731

      Here’s a script that I recently wrote to handle a slightly similar situation. I had to reorder the NTE segments. I used a counter and a flag. There is probably a better way to do it, but maybe this will get you started.

      Code:

      proc tps_reorderNTE { args } {
         package require extexpfilter
         keylget args MODE mode

         switch -exact — $mode {
             start {
                 # Do nothing.
             }

             run {
                 set debug 0
                 keylget args MSGID mh
                 set msg [msgget $mh]
                 set dispList “{CONTINUE $mh}”

                 # Put the segments into a list
                 set segList [split $msg r]

                 # Initialize the counter
                 set i 0

                 # Get the OBR-NTE segments
                 foreach segment $segList {
                     set segName [string range $segment 0 2]
                     if {$segName == “OBX”} {
                         break
                     }
                     if {$segName == “NTE”} {
                         lappend obrNte $segment
                         lappend nteLoc $i
                     }
                     set i [expr $i + 1]
                 }

                 # Insert the OBR-NTE segments into the segment list
                 set newMsg [linsert $segList [expr $i + 1] [join $obrNte r]]

                 # Remove the OBR-NTE segments
                 set newMsg [lreplace $newMsg [lindex $nteLoc 0] [lindex $nteLoc end]]

                 # Return the new, re-ordered message
                 msgset $mh [join $newMsg r]

                 return $dispList
             }

             shutdown {
                 # Do nothing.
             }

             default {
                 # Do nothing.
             }
         }
      }

      -- Max Drown (Infor)

    • #67732
      Charlie Bursell
      Participant

      I still don’t think you have completely stated your problem.

      In an OBX segment, field 8 is the Abnormal Flags field.  Are you saying if there is a P in there anywhere or are you saying literaly “*P”?

      You say append ABN to end of first segment.  Are you sure you do not want this in field 8 of first OBX segment?  What if there are only 6 fileds?  If you append to the end it will be in field 7.

      Making some *REAL* broad assumptions

      set msg [msgget $mh]

      set fldSep [string index $msg 3]

      set segments [split $msg r]

      # Location of first OBX

      set loc1 [lsearch -regexp $segments {^OBX}]

      # Loop through all  OBX or until P is found

      foreach obx [lsearch -all -inline -regexp {^OBX}] {

          # Get Abnormal flags

          set flags  [lindex  [split $obx $fldSep] 8]

          if {[regexp — {P} $flags]} {

                set OBX1 [split [lindex $segments $loc1] $fldSep]

                # In case of less than 8 fields

                while {[llength $OBX1] <= 9} {lappend OBX1 {}}

                set OBX1 [lreplace $OBX1 8 8 ABN]

                set segments [lreplace $segments $loc1 $loc1

                           [join $OBX1 $fldSep]]

                 break

            }

      }

      # Assume change was made

      msgset $mh [join $segments r]

      return “{CONTINUE $mh}”

      If I made wrong assumptions, logic should still be the same, just change it

    • #67733
      Femina Jaffer
      Participant

      Thanks Charlie and Max, for your response.

      Charlie, per your questions:

      The ‘*P” is contained in the OBX 5 if the test is positive for a culture.  Literally, I am looking for the “*P“.  It doesn’t matter where I append the “ABN” too, as long as it is in the end of the 1st OBX.

      Another alternative if you can help me which might be easier:  Instead of looking for the “*P”, I could look for an “ABN” in any OBX segment.  If found, I need to take too append it to the 1st OBX at the end.

      Thanks Femina

    • #67734
      Femina Jaffer
      Participant

      One more thing.  the ‘ABN’ or ‘*P’ will NEVER be in the first occurance of the OBX segment (eg. OBX|1|||| ).

    • #67735
      Charlie Bursell
      Participant

      Simply modify the code

      set msg [msgget $mh]

      set fldSep [string index $msg 3]

      set segments [split $msg r]

      # Location of first OBX

      set loc1 [lsearch -regexp $segments {^OBX}]

      # Loop through all  OBX or until P is found

      foreach obx [lsearch -all -inline -regexp {^OBX}] {

         # Get Abnormal flags

         set flags  [lindex  [split $obx $fldSep] 5]

         if {[regexp -nocase — {*P} $flags]} {

               set OBX1 [split [lindex $segments $loc1] $fldSep]

               lappend OBX1 ABN

               set segments [lreplace $segments $loc1 $loc1

                          [join $OBX1 $fldSep]]

                break

           }

      }

      # Assume change was made

      msgset $mh [join $segments r]

      return “{CONTINUE $mh}”

    • #67736
      Femina Jaffer
      Participant

      Charlie,

      when I test this code…

      foreach obx [lsearch -all -inline -regexp {^OBX}] {

       echo obx $obx

      I do not get anything returned using the echo. ??

    • #67737
      Femina Jaffer
      Participant

      Never mind.  I figured it out.  I modified the line too..

      foreach obx [lsearch -all -inline -regexp $segments {^OBX}] {

      Thanks for all your help!!

    • #67738
      Charlie Bursell
      Participant

      Can’t think of everything  🙄

    • #67739

      Charlie, that is real useful code. I’m going to be re-using the basic concept lots and lots in the future. Thanks for posting it.

      Specifically, the “[lsearch -all -inline -regexp $segments {^OBX}]” bit.

      -- Max Drown (Infor)

    • #67740
      Femina Jaffer
      Participant

      This code worked!  Thank you so much Charlie, like Max said earlier – “very useful”.  I’ll definitely be using this again and again.

      Femina

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

Forum Statistics

Registered Users
4,964
Forums
28
Topics
9,103
Replies
33,613
Topic Tags
248