Remove (Parentheses) from HL7 using Tcl

Homepage Clovertech Forums Read Only Archives Cloverleaf Tcl Library Remove (Parentheses) from HL7 using Tcl

  • Creator
    Topic
  • #50396
    Bill Tipton
    Participant

    Hello,

    I’m new to Tcl

    I need help in trying to remove (???) the parentheses within an HL7

    message using Tcl code.  Does someone have a quick and easy way to do that?   😕

Viewing 4 reply threads
  • Author
    Replies
    • #65949

      Bill, can your provide a little more detail including some examples?

      -- Max Drown (Infor)

    • #65950
      Robert Kersemakers
      Participant

      Hi Bill,

      If you mean you want to replace the active Null “” with nothing, then try this:

      Code:

      regsub -all “” $msg “” msg

      Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

    • #65951
      Jim Kosloskey
      Participant

      Robert,

      Pre Cloverleaf(R) 5.7 I don’t think that will work as the field’s datatype attribute needs to be changed as well.

      I think in Cloverleaf(R) 5.7 they have made this much easier to do.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #65952
      Tom Rioux
      Participant

      If you are truly looking to remove the left paren “(” and the right paren “)” then you may have to do this in separate regsub statements.  I assume you are wanting to leave any part of the text that is between the parenthesis and leave it blank where the parenthesis was.  Try this:

      Lets say the text is:

      Long term (current) use of medications.

      You will need to double escape the parenthesis in order to replace them:

      hcitcl>set text “Long-term (current) use of medications”

      Long-term (current) use of medications

      hcitcl>regsub -all \( $text “” newtext

      1

      hcitcl>regsub -all \) $newtext “” newtext

      1

      hcitcl>echo $newtext

      Long-term current use of medications

      Hope this helps….

      Tom Rioux

    • #65953
      Bill Marsch
      Participant

      Here is a tcl that you can pass a field to it and remove the left and right parens from and replace them using the “string map” command:

      ######################################################################

      # Name: tpsremoveparen

      # Purpose:

      # UPoC type: xltp

      # Args: none

      # Notes: All data is presented through special variables.  The initial

      # upvar in this proc provides access to the required variables.  

      # The expected InVal is a field to remove left and right parens

      #

      # This proc style only works when called from a code fragment

      # within an XLT.  

      #

      proc tpsremoveparen {} {

         upvar xlateId       xlateId

       xlateInList   xlateInList

       xlateInTypes  xlateInTypes

       xlateInVals   xlateInVals

       xlateOutList  xlateOutList

       xlateOutTypes xlateOutTypes

       xlateOutVals  xlateOutVals

         set fld1 [lindex $xlateInVals 0]

             if { [clength $fld1] > 2 } {

                 set y [string map {( “” ) “”} $fld1]

                }

      #echo n “range is ” $y

         set xlateOutVals “$y”

         

      }

Viewing 4 reply threads
  • The forum ‘Tcl Library’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,293
Replies
34,435
Topic Tags
286
Empty Topic Tags
10