Reply To: replacing text in an HL7 ADT (TCL)

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

#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

Forum Statistics

Registered Users
5,116
Forums
28
Topics
9,292
Replies
34,432
Topic Tags
286
Empty Topic Tags
10