Frank,
I have tested the following code against your samples and it worked fine for me.
Like Scott, I started with a COPY of PV1.7.1 and FT1.3 into FT1.3
COPY
SOURCE DESTINATION
====== =========
PV1.7.1 FT1.3
FT1.3
Pre-Tcl:
lassign $xlateInVals pv1_7_1 ft1_3
# echo >>> pv1_7_1: $pv1_7_1
# echo >>> ft1_3: $ft1_3
# Check for the pattern “–” in FT1.3; that would indicate a missing part2
# since FT1.3 should be part1-part2-part3
if {[regexp — {–} $ft1_3]} {
# collect part1 and part3 of the string
regexp (\w+)–(\w+) $ft1_3 all part1 part3
# echo >>> part1: $part1
# echo >>> part3: $part3
# Build our output by concatenating the appropriate parts with dashes
# (Could also use a join command)
# Always return xlateOutVals as a list
set xlateOutVals [list $part1-$pv1_7_1-$part3]
} else {
# The string in FT1.3 came in complete. Nothing to do.
set xlateOutVals [list $ft1_3]
}
In the HL7 variant that I used (version 2.3), the default length of FT1.3 was only 10 characters. I had to increase the length to 20 in order to hold the string sent.
I hope this helps.