replacing text in an HL7 ADT (TCL)

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf replacing text in an HL7 ADT (TCL)

  • Creator
    Topic
  • #47785
    Doug Stelley
    Participant

    Using 3.8.1p, in a windows environment.

    I can fing the strings I want OK

    All is good,

    I can determine whether I want to change them

    All is good,

    by using  Lappend :

    lappend PV1_fld10 $PV2_fld3$PV1_fld10

    the resulting string is what I want.

    Now, how do I replace the original with the new value?

    my outgoing message doen’t seem to be affected.

    I included the tcl I’m using since I’m probably not to clear in my question…

Viewing 1 reply thread
  • Author
    Replies
    • #56711
      Jonathan Hamilton
      Participant

      Just work backwards using lreplace and join instead of split and lindex.

      set data [msgget $mh]

      set fld_delim [cindex $data 3]

      set split_data [split $data r]

      set pv1_index [lsearch $split_data “PV1*”]

      if {$pv1_index == -1} {error “No PV1 segment!”}

      set pv1 [lindex $split_data $pv1_index]

      set split_pv1 [split $pv1 $fld_delim]

      # Now start changing the data and work towards a new message.

      set split_pv1_new [lreplace $split_pv1 2 2 “New Data”]

      set pv1_new [join $split_pv1_new $fld_delim]

      set split_data_new [lreplace $split_data $pv1_index $pv1_index $pv1_new]

      set data_new [join $split_data_new r]

      msgset $mh $data_new

    • #56712
      David Caragay
      Participant

      Since we do this type of manipulation quite often, I have a tcl proc that I use to store examples of frequently used code fragments.

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

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,295
Replies
34,439
Topic Tags
287
Empty Topic Tags
10