Homepage › Clovertech Forums › Cloverleaf › remove \F\ or \T\ or \R\ or \T\ from an HL7 field
- This topic has 7 replies, 5 voices, and was last updated 1 year, 6 months ago by Charlie Bursell.
-
CreatorTopic
-
March 23, 2023 at 11:09 am #120415JDParticipant
Hello – I need to remove occurances of \F\ or \T\ or \R\ or \T\ within a field in HL7 Oru messages. How can I remove the occurances within an xlate? Thanks in advance.
-
CreatorTopic
-
AuthorReplies
-
-
March 23, 2023 at 11:28 am #120416Scott CaldwellParticipant
Here is how I am doing it with removing a “\.br\” via script:
set lstSegments [split $origMsg \r]
#loop through segments
#echo “foreach line 153”foreach valSeg $lstSegments {
set segType [mjhGetField 0 $valSeg $fieldSep]# ——————————————————————
# —————————————————————— MSH
# ——————————————————————
if [cequal $segType NTE] {
#echo $valSeg
set CountVal 1
set CheckString [mjhGetField 3 $valSeg $fieldSep]
set MarkupExists [string match *\.br\* $CheckString]
while { [cequal $MarkupExists 1] } {
#echo “loop start”
#echo equality:[cequal $MarkupExists 1]
#echo [string first “\\.br\\” $CheckString]
#echo [string range $CheckString 0 [string first “\\.br\\” $CheckString]-1 ]
set valSeg [mjhSetField [string range $CheckString 0 [string first “\\.br\\” $CheckString]-1 ] 3 $valSeg $fieldSep]
set valSeg [mjhSetField $CountVal 1 $valSeg $fieldSep]
lappend newMSGx $valSeg
#echo $valSeg
set CheckString [string range $CheckString [string first “\\.br\\” $CheckString]+5 end]
#echo $CheckStringincr CountVal
set MarkupExists [string match *\.br\* $CheckString]
#echo MarkupExists:$MarkupExists
#echo CountVal:$CountVal
if [cequal $MarkupExists 0] {
set valSeg [mjhSetField $CheckString 3 $valSeg $fieldSep]
set valSeg [mjhSetField $CountVal 1 $valSeg $fieldSep]
#lappend newMSGx $valSeg}
}}
lappend newMSGx $valSeg
} -
March 23, 2023 at 11:50 am #120417Paul BishopParticipant
You can do it with a string map command without looping through and finding each occurrence. I do question why they need to be removed – those are valid escape sequences in HL7 that should be replaced in the destination system when the message is filed. For example, “\R\” would be replaced by “~” (assuming “|^~\&” on the MSH segment). I do remember having to do this for a vendor’s embedded and encoded PDF one time because they went through and replaced all the delimiter characters in the encoded PDF – made for a magnificent crash when decoding the PDF.
To do it properly, you should pull out the delimiter characters from the MSH field first and use those rather than hard-coding values. Assuming this is done in a UPOC tcl:
keylget args MSGID mh
set msg [msgget $mh]
#separator
set fldSep [string index $msg 3]
set subSep [string index $msg 4]
set repSep [string index $msg 5]
set escSep [string index $msg 6]
set sb2Sep [string index $msg 7]set map_list
# pull out the field from the message you want to change, for example an OBX-5 value, then use the string map command
set obx_5 [string map $map_list $obx_5]# then replace the OBX-5 value in the message with the one you just fixed above.
If you need more detail on the pulling out and replacing of fields, I can provide that information as well.
Doing this within a translate is also possible, although I’ve never done it that way. Same concept, just a TCL fragment on the OBX-5 copy.
Paul Bishop
Carle Foundation Hospital
Urbana, IL -
March 23, 2023 at 11:58 am #120418Jim KosloskeyParticipant
Depending on the CL release this can be done with the STRING Action map Function as well.
It is still a good idea to use the MSH indicated escape character just in case the message uses something different than the standard. That can be acquired as well using the STRING Xlate Action.
If you are not familiar with the STRING Action and all of its actions, I have a presentation describing what is available. If you would like that, email me.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
March 23, 2023 at 11:51 pm #120422Charlie BursellParticipant
Simple if it is just one field.
In translate caputure the field then:
set inp [lindex $xlateInVals 0]
set xlateOutVals$inp]]
-
-
AuthorReplies
- You must be logged in to reply to this topic.