Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Does ay have a tclproc to add value into a segment
- This topic has 7 replies, 4 voices, and was last updated 11 years, 12 months ago by Kevin Crist.
-
CreatorTopic
-
September 24, 2012 at 6:09 pm #53290Sebastien BazileParticipant
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
-
CreatorTopic
-
AuthorReplies
-
-
September 24, 2012 at 6:53 pm #77165Jim KosloskeyParticipant
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.
-
September 24, 2012 at 6:56 pm #77166Sebastien BazileParticipant
I want to put ADT in MSH.3
-
September 24, 2012 at 6:59 pm #77167Sebastien BazileParticipant
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
-
September 24, 2012 at 7:05 pm #77168Jim KosloskeyParticipant
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.
-
September 24, 2012 at 8:02 pm #77169Adriana RodriguezParticipant
Sebastien,
I’ve attached a proc to add ADT to MSH:3. Hope this helps.
-
September 24, 2012 at 8:05 pm #77170Adriana RodriguezParticipant
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’.
-
September 25, 2012 at 12:54 pm #77171Kevin CristParticipant
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 MSHset SegName “” ;# User Supplied Segment to Change
set FieldNum 0 ;# User Supplied Field Num to Change
set FieldVal “” ;# User Supplied Value to set in Field Numset 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 messageset fldSep [string index $msg 3] ;# Field Seperator
set subSep [string index $msg 4] ;# Sub-Field Seperator
set repSep [string index $msg 5] ;# Repeating Field Seperatorset 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 Switchreturn $dispList
} ;# End Proc
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.