Does ay have a tclproc to add value into a segment

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Does ay have a tclproc to add value into a segment

  • Creator
    Topic
  • #53290
    Sebastien Bazile
    Participant

    I’m having issues with my xlate so I’m having to write a new tcl proc to add “ADT” in MSH.3 for a client  and I can’t seem to have it worked out because of my lack of tcl knowledge. can anyone help.

    thank you.

    Seb

Viewing 6 reply threads
  • Author
    Replies
    • #77165
      Jim Kosloskey
      Participant

      I am not sure why you would need Tcl for that.

      Do you just want to add ADT to what is in MSH-3 or do you want to put ADT in MSH-3?

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

    • #77166
      Sebastien Bazile
      Participant

      I want to put ADT in MSH.3

    • #77167
      Sebastien Bazile
      Participant

      Right now, the MSH-3 field is empty and the vendor wants me to add “ADT” in field 3. I don’t have a working xlate so I can’t do a bulkcopy. So the only way I can do it is by writing a tcl proc and I’m not that knowledgeable.

      thank you

    • #77168
      Jim Kosloskey
      Participant

      Sebastien,

      OK now I understand – you don’t have any Xlate at all. Probably no variants either. Also probably lacking vendor specifications.

      Sorry I don’t have something for you – we use the Xlate to build messages here. We reserve the use of Tcl for that which the Cloverleaf toolset will not do.

      Perhaps someone else has a proc you can use.

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

    • #77169
      Adriana Rodriguez
      Participant

      Sebastien,

      I’ve attached a proc to add ADT to MSH:3.  Hope this helps.

    • #77170
      Adriana Rodriguez
      Participant

      FYI – The previously attached TCL proc description reads “This proc will change MSH:9” but the logic has been adjusted to code the MSH:3 field with ‘ADT’.

    • #77171
      Kevin Crist
      Participant

      Give this a whirl. just plug in the appropriate arguments.

      Code:


      #########################################################################################
      #########################################################################################
      #########################################################################################
      # Name: tpsSetFieldValue.tcl
      # Purpose: This tps tclproc sets the specified Field in the specified Segment
      # to a specified Value.
      # If the Segment or the Field Number are omitted, the message will be
      # continued as is and an entry will be made in the engine log.
      # If there are mutilple occurances of the segment, all of them will be
      # modified.
      # If the Field Value is omitted, the Segment/Field specified will be
      # set to “”.
      # If the segment does not exist in the message, the message will be
      # continued and an entry will be put in the engine log.
      # If the field does not exist in the message but the segment does,
      # blank fields will be added to create the space for the field number
      # specified.
      # The field numbers start with 0, ie the 3rd field is field number 2.
      #
      # UPoC type: tps
      # Args: tps keyedlist containing the following keys:
      #       MODE    run mode (”start”, “run” or “time”)
      #       MSGID   message handle
      #       ARGS    user-supplied arguments:
      # 1) The user specified Segment
      # The key is SEGMENT
      # 2) The user can specify the Field Number
      # The key is FIELDNUM
      # 3) The user can specify the Field Value
      # The key is FIELDVAL
      #
      #
      # Example arguments: {SEGMENT OBR} {FIELDNUM 25} {FIELDVAL F}
      # This will force OBR-25 to a value of “F” for every message
      # {SEGMENT OBR} {FIELDNUM 25} {FIELDVAL {}}
      # This will force OBR-25 to be an empty field
      # (you can not use “” for null)
      #
      #
      # Returns: tps disposition list:
      #          Continues the modified message
      # OR
      # Continues the Un-modified message (if bad ARGS passed in)
      #
      # Created: John Zalesak 04/15/2009
      #
      #
      #########################################################################################
      #########################################################################################
      #########################################################################################

      proc tpsSetFieldValue { args } {

      #########################################################################################
      # Get the Connection/Proc Name for Error/Debug Messages
      #########################################################################################

      global HciConnName
      set myname “$HciConnName/[lindex [info level 1] 0]”
      set nowis [clock format [clock scan now] -format “%D – %T”]

      #########################################################################################
      # Initialize Variables Used
      #########################################################################################

      set dispList [list] ;# Disposition List Returned to Engine

      set fldSep “” ;# Field Seperator – get from MSH
      set subSep “” ;# SubField Seperator – get from MSH
      set repSep “” ;# Repeating Field Seperator – get from MSH

      set SegName “” ;# User Supplied Segment to Change
      set FieldNum 0 ;# User Supplied Field Num to Change
      set FieldVal “” ;# User Supplied Value to set in Field Num

      set segList [list] ;# Message Segments in List Form

      set SegPos [list] ;# List of Seg Pos in segList that match
      ;#  the User Supplied Segment Name

      #########################################################################################
      # Load in the arguments we need that were passed from the caller
      #########################################################################################

      keylget args MODE mode             ;# The mode the engine called from
      keylget args ARGS.SEGMENT SegName ;# Segment Name
      set SegName [string toupper $SegName] ;# Force to uppercase
      keylget args ARGS.FIELDNUM FieldNum ;# Field Number to Change
      keylget args ARGS.FIELDVAL FieldVal ;# Value to Set Field To

      #########################################################################################
      # Switch based on what mode the engine was in when it called the procedure
      #########################################################################################

       switch -exact — $mode {

         run {
          set mh [keylget args MSGID] ;# Get message handle from args
         set dispList [list “CONTINUE $mh”] ;# Initialize to good message
           set msg [msgget $mh] ;# Get a copy of the message

           set fldSep [string index $msg 3] ;# Field Seperator
           set subSep [string index $msg 4] ;# Sub-Field Seperator
           set repSep [string index $msg 5] ;# Repeating Field Seperator

      set segList [split $msg r] ;# Split message into segList

      #########################################################################################
      # Validate the user supplied values
      #########################################################################################

      if { $SegName == “” } {
       echo n n
       echo “==========================================================”
        echo “:WARN – No Segement Name Was Supplied !”
       echo “:WARN – Message Continued As Is.”
       echo “:WARN – Here Is: $myname”
       echo “:WARN – Now Is: $nowis”
       echo $msg
       echo “==========================================================”  
       echo n n
             return $dispList
      }

      if { $FieldNum == “” || $FieldNum == 0 } {
       echo n n
       echo “==========================================================”
        echo “:WARN – Invalid or No Field Number Was Supplied !”
        echo “:WARN – Field Number is: “$FieldNum””
       echo “:WARN – Message Continued As Is.”
       echo “:WARN – Here Is: $myname”
       echo “:WARN – Now Is: $nowis”
       echo $msg
       echo “==========================================================”  
       echo n n
             return $dispList
      }

      #########################################################################################
      # Find Position of Segement(s) – If missing -> Continue Message and Return
      #########################################################################################

      set SegPos [lsearch -all -regexp $segList “^$SegName”]

      if { [lindex $SegPos 0] < 0 } {
       echo n n
       echo "=========================================================="
        echo ":WARN – Segment "$SegName" Is Missing !"
       echo ":WARN – Message Continued As Is."
       echo ":WARN – Here Is: $myname"
       echo ":WARN – Now Is: $nowis"
       echo $msg
       echo "=========================================================="  
       echo n n
             return $dispList
      }

      #########################################################################################
      # Force the Segment/Field Value – Add Blank fields is Seg is too short.
      #########################################################################################

      foreach Seg $SegPos {
      set fldList [split [lindex $segList $Seg] $fldSep]
      set fldCnt [llength $fldList]

      for { set flds $fldCnt } { $flds < [expr $FieldNum + 1] } { incr flds } {
        lappend fldList {}
        }
       
        lset fldList $FieldNum $FieldVal
       
        lset segList $Seg [join $fldList $fldSep]
       
        }

      #########################################################################################
      # Recreate the message and store back at msg handle
      #########################################################################################

       set msg [join $segList r]  
       
         msgset $mh $msg

      }

      start { }
         time { }
         shutdown { }
         default {
          echo ":WARN"
          echo ":WARN ======================================"
       echo ":WARN – tps called with invalid mode !"
      echo ":WARN – Mode Is: $mode"
      echo ":WARN – Here Is: $myname"
      echo ":WARN – Now Is: $nowis"
      echo ":WARN ======================================"
      echo ":WARN"
         }
      } ;# End Switch

      return $dispList

      } ;# End Proc

Viewing 6 reply threads
  • The forum ‘Cloverleaf’ 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