remove \F\ or \T\ or \R\ or \T\ from an HL7 field

Clovertech Forums Cloverleaf remove \F\ or \T\ or \R\ or \T\ from an HL7 field

  • Creator
    Topic
  • #120415
    JD
    Participant

      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.

    Viewing 3 reply threads
    • Author
      Replies
      • #120416
        Scott Caldwell
        Participant

          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 $CheckString

          incr 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
          }

          • #120419
            JD
            Participant

              Thank you – I’d need to play around with the tcl.  Good reference though. Can it be down via xlate?

          • #120417
            Paul Bishop
            Participant

              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

                • #120420
                  JD
                  Participant

                    Thanks – good reference; I’m hoping to this this in an xlate if possible.

                • #120418
                  Jim Kosloskey
                  Participant

                    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.

                    • #120421
                      JD
                      Participant

                        Thanks – looking at the string map option. Seems to work from tclsh prompt.  Now try in xlate.  Appreciate the offer, I may be ok, will find out this afternoon.

                    • #120422
                      Charlie Bursell
                      Participant

                        Simple if  it is just one field.

                        In translate caputure the field then:
                        set inp [lindex $xlateInVals 0]
                        set xlateOutVals

                          $inp]]

                           

                      Viewing 3 reply threads
                      • You must be logged in to reply to this topic.