NK1|1|TEST^TWO^^||1570 NW PATRICK^^CORVALLIS^OR^97330^USA|(541)924-3801^^PH~(541)974-6780^^CP
and change to
NK1|1|TEST^TWO^^||1570 NW PATRICK^^CORVALLIS^OR^97330^USA|^PHN^PH^^541^9243801~^PHN^CP^^541^9746780
This is the logic in my tcl proc:
set fieldList “”
if {[cequal $segid “NK1”]} {
set fieldList [split $segment |]
set nk15 [lindex $fieldList 5]
set nk15Flds [split $nk15 ~]
foreach group $nk15Flds {
set grpLst [split $group ^]
set subfld0 [lindex $grpLst 0]
set subfld1 [lindex $grpLst 1]
set subfld2 [lindex $grpLst 2]
}
set newSubfld [concat ^PRN^$subfld2^$subfld0]
set newsubfld0 [regsub {-} $newSubfld “”]
set newsubfld01 [regsub {[)]} $newsubfld0 ^]
set newsubfld0f [regsub {[(]} $newsubfld01 ^]
echo “newSubfld = $newsubfld0f “
set newnk15Lst [lappend newnk15Lst $newsubfld0f]
echo “newnk15List = $newnk15Lst”
set newnk15 [join $newnk15Lst ~]
set nk1Seglist [lreplace $fieldList 5 5 $newnk15]
set newnk1Seg [join $nk1Seglist |]
set msgseglist [lreplace $msgseglist $count $count $newnk1Seg]
}
this is what I’m getting as a result… it appears to drop the first subfield :
NK1|1|TEST^TWO^^||1570 NW PATRICK^^CORVALLIS^OR^97330^USA|^PRN^CP^^541^9746780
Any help is very appreciated