I am trying to remove a segment that contains ICD10 value and keep just the ICD9. Below I have the sample message, how I want the message to be after the tcl and I also provide the tcl so far.
I believe it is something simple but I can’t delete the whole segment and rebuild the message without that segment.
Thanks you in advance.
Here is my sample message with all the ICD
‘MSH:;~&:HBOC:H:ESCM:H:201312051550::ADT;A08;44:7149988:T:2.2:7149988::AL::
EVN:A08:201312051550::
PID::01369515:1300131;;;H:4050;H4880:TEST;JOHN;””;””:””:19671222:M::1:22 TEST ST;””;NEW YORK;NY;10021;US;C;60~””;””;””;””;””;””;P;””:60:(212)555-6777::ENGLISH;E;:””;””:””;””:70100129;;;H:””:
PD1::::””;;;;;;;;;;;;;;;;:::””;””:””;””:::””:N:””;””
PV1::O:””;””;””;H;;””;””:1::;;;H:212;DELAND;JONATHAN;””;;;MD:212;DELAND;JONATHAN;””;;;MD::FTA::::1::””:212;DELAND;JONATHAN;””;;;MD:SVO;;H:70100129;;;H:6::::””::::::::::::””;””:::H:””;””::::201312051504:””::::
PV2::””::””:””:””::””:””:””:””:N:0:””
DG1:0:I9:564.1:IRRITABLE
DG1:1:I9:564.1:IRRITABLE
DG1:0:I10:A00.0:Cholera
DG1:1:””:A00.1:Cholera
GT1:1:4050:TEST;JOHN;””;””::22 TEST ST;””;NEW YORK;NY;10021;US;C;60~””;””;””;””;””;””;P;””:(212)555-6777::19671222:M::S:””:::1:::::
IN1:1:040:040:WORK COMP:””;””;””;””;””;””;C;””:””:””:””:””:::””:””::C;;:TEST;JOHN;””::19671222::::::::::””::::::::””:::::::M::””
I would like the message to be like below
‘MSH:;~&:HBOC:H:ESCM:H:201312051550::ADT;A08;44:7149988:T:2.2:7149988::AL::
EVN:A08:201312051550::
PID::01369515:1300131;;;H:4050;H4880:TEST;JOHN;””;””:””:19671222:M::1:22 TEST ST;””;NEW YORK;NY;10021;US;C;60~””;””;””;””;””;””;P;””:60:(212)555-6777::ENGLISH;E;:””;””:””;””:70100129;;;H:””:
PD1::::””;;;;;;;;;;;;;;;;:::””;””:””;””:::””:N:””;””
PV1::O:””;””;””;H;;””;””:1::;;;H:212;DELAND;JONATHAN;””;;;MD:212;DELAND;JONATHAN;””;;;MD::FTA::::1::””:212;DELAND;JONATHAN;””;;;MD:SVO;;H:70100129;;;H:6::::””::::::::::::””;””:::H:””;””::::201312051504:””::::
PV2::””::””:””:””::””:””:””:””:N:0:””
DG1:0:I9:564.1:IRRITABLE
DG1:1:I9:564.1:IRRITABLE
GT1:1:4050:TEST;JOHN;””;””::22 TEST ST;””;NEW YORK;NY;10021;US;C;60~””;””;””;””;””;””;P;””:(212)555-6777::19671222:M::S:””:::1:::::
IN1:1:040:040:WORK COMP:””;””;””;””;””;””;C;””:””:””:””:””:::””:””::C;;:TEST;JOHN;””::19671222::::::::::””::::::::””:::::::M::””
Here is the code I have so far
proc removeicd10 { args } {
set mode [keylget args MODE]
set context [keylget args CONTEXT]
switch -exact — $mode {
start {
return “” ;# no specific startup
}
run {
set ibid [keylget args MSGID]
if {$context != “sms_ib_data”} {
echo “No reply generated; wrong context $context”
return “{CONTINUE $ibid}”
}
set datList [datlist]
; # first get control id from inbound message
set msg [msgget $ibid]
set segmentlist [split $msg r]
set newSegmentList “”
foreach segment $segmentlist {
if {[crange $segment 0 2] == “DG1”} {
set fieldlist [split [lindex $segment 0] :]
set temp1 $fieldlist
set temp2 [lsearch -all -inline $temp1 I10]
echo $temp1
set segment [join $fieldlist :]
#set temp [lsearch -all -inline -not $fieldlist I10]
#echo $temp
}
set newSegmentList [lappend newSegmentList $segment]
}
set newSegmentList [join $newSegmentList r]
msgset $ibid $newSegmentList
;# msgdump $ibid
return “{CONTINUE $ibid}”
}
shutdown {
# Doing some clean-up work
}
default {
return “” ;# don’t know what to do
}
}
}