Removing duplicates from PV1_19 HL7 field

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Removing duplicates from PV1_19 HL7 field

  • Creator
    Topic
  • #55006
    Sucharitha Manyala
    Participant

    How can I delete duplicates from repeating HL7 field PV1_19?

Viewing 7 reply threads
  • Author
    Replies
    • #83777
      James Cobane
      Participant

      Do you need to remove true duplicates or simply extraneous repetitions (i.e. only want the first repetition, toss the others)?

      Jim Cobane

      Henry Ford Health

    • #83778
      Sucharitha Manyala
      Participant

      I want to remove true duplicates like if PV1_19 is “a1~a2~a3~a1~a2” I want to map only “a1~a2~a3” to the outbound.

    • #83779
      Jim Kosloskey
      Participant

      Are you using an Xlate?

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #83780
      Sucharitha Manyala
      Participant

      I was thinking of doing it in Xlate but looks liek it is easy to do it in TPS proc. So i re-built message and used “lrmdups” command to remove duplicates. It worked for me. Thanks for looking into it.

    • #83781
      Charlie Bursell
      Participant

      In Tcl it is easy enough.  Jim may have an Xlate method

      I will assume you know how to split an HL7 message in Tcl.

      Assume sements are in variable segList and separator characters were captured similar to:

      set fldSep [string index $msg 3]

      set subSep [string index $msg 4]

      set iterSep [string index $msg 5]

      sep loc [lsearch -regexp $segList {^PV1}]

      set pv1 [split [lindex $segList $loc] $fldSep]

      set fld19 [split [lindex $pv1 19] $iterSep]

      # if order in the list is not important then:

      set fld19 [join [lsort -unique $fld19] $iterSep]

      # to maintain order (assuming you have Tcl 8.6):

      foreach element $fld19 {dict set tmp $element}

      set fld19 [join [dict keys $tmp] $iterSep]

      # then:

      set pv1 [lreplace $pv1 19 19 $fld19]

      set segList [lreplace $segList $loc $loc [join $pv1 $fldSep]]

      msgset $mh [join $segList r]

      return “{CONTINUE $mh}”

      Be advised I can and do fat finger some things  this is off the top of my pointed head

    • #83782
      James Cobane
      Participant

      If your using an Xlate, you could do it within the existing Xlate and simply build a list in a temp variable as you ITER through, comparing the current iteration to the elements in the list of the temp variable.  If the current iteration value is in the list simply don’t copy it to the outbound side (and don’t add it to the temp variable).  You would have to keep track of your own iteration variable on the output side though.

      Hope that makes sense.

      Jim Cobane

      Henry Ford Health

    • #83783
      Sucharitha Manyala
      Participant

      Thanks Charlie and James. I did it in my TPS pre-proc before xlate where I rebuilt HL7 message after deleting duplicates with “lrmdups” command. It seems to be working fine.

    • #83784
      Jim Kosloskey
      Participant

      I believe lrmdups also sorts so if order is important you might not want to do it that way.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,448
Topic Tags
288
Empty Topic Tags
10