Removing a single quote from entitlement field or PID 5_3

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Removing a single quote from entitlement field or PID 5_3

  • Creator
    Topic
  • #51597
    Yamil Velez
    Participant

      Hi All

         I am trying to create a tcl script that would only go to PID 5_3 field and remove any quotes.  

      Below is my proc, when I run this proc it removes quotes throughtout the whole message.  I really want it to remove it just from the PID 5_3 or the patient name suffix field

      Thank you very much for the help

      Yamil

      proc remove_singlequotes { args } {

         set mode [keylget args MODE]               ;# What mode are we in

         set context [keylget args CONTEXT]               ;# What mode are we in

         switch -exact — $mode {

             start {

                 return “” ;# Perform special init functions

             }

             run {

                 keylget args MSGID mh

                 set msg [msgget $mh]

                 

                     

                 

                     regsub -all — {x22} $msg {} new_msg

                   #

                 # replace msg by new_msg

                   msgset $mh $new_msg

                 set returnList “{CONTINUE $mh}”

                 return $returnList

             default {

                 echo “Unknown mode in : ‘$mode'”

                 return “”                   ;# Dont know what to do

             }

         }

      }

      }

    Viewing 2 reply threads
    • Author
      Replies
      • #70919
        Nick Stainback
        Participant

          It looks like you will need to do is seperate the message out and set a $Var for the PID 5.3 and then use that $Var in the command you already have

          “regsub -all — {x22} $Var {} New_PID5.3”

          Then place the new PID segment back in to the message

          Hope this Helps.

        • #70920
          Yamil Velez
          Participant

            Hi Nick

              I am confused, how do I direct it to look at just PID 5.3

            Yamil

          • #70921
            Nick Stainback
            Participant

              Now there may be other ways to do this but this is what I would do…

              You will have to take the message apart make your change and then put it back together with the updates

              For Example:

              set msg [msgget $mh]

              set segList [split $msg r]

              ######PID######

              ##Get SeG###

              ##Search for Seg

              set segPID [lindex [lsearch -all -inline $segList PID*] 0]

              ##Set Field Sep and Lists##

              ##Set Feild Sep

              set feildSep [string index $msg 3]

              ####Set FieldList

              set fl [split $segPID $feildSep]

              ####Set Fields

              set fieldPID5 [lindex $fl 5]

              #If you have to get down to the Subfield then just use the same logic to use the subfield sep to get subfield 3

              #once you have the field or subfield you want run your command on that field/subfield in this case $fieldPID5 would use the entire field

              regsub -all — {x22} $fieldPID5 {} New_PID53

              #Then Place the new PID 5 back in the PID segement

              ####Replace feild

              set newfl [lreplace $fl 5 5 $New_PID53]

              ####place the Feild Sep back into each new field list

              set newSeg [join $newfl $feildSep]

              set pos [lsearch -regexp $segList ^PID]

              ####Replace Seg with new Seg

              set nseg [lreplace $segList $pos $pos $newSeg]

              ####Re-Build the Message

              set nmsg [join $nseg r]

              msgset $mh $nmsg

              Hope this Helps,

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.