› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Filtering messages › Reply To: Filtering messages
We do a fair bit of this kind of thing and our method may not be applicable to you!
We set the inbound thread routing to FRL and a ‘proc’ and use TCL code to return a route type and go from there.
In the example below (used in a ‘timing’ site and not production), we will be receiving multiple hospital ADT messages on a thread and wish to route them based on information (hospital code) in the MSH segment.
When we use this routing code in production, we ensure that the code returns a ‘bad’ route for any error and route this to a SMAT file, so we can produce a report.
proc tim_code_trx {aMsgId} {
#
# grab the first part of the message, containing the MSH
#
set myMsh [csubstr [msgget $aMsgId] 0 60]
set myFS [csubstr $myMsh 3 1]
#
# split the segment into the fields and return the third field
# should be PJ@
#
set myTrxId [lindex [split $myMsh $myFS] 2 ]
return “$myTrxId”
}
This is a Unit Test script for routing code and may make testing easier.
#!/usr/bin/ksh
# this line to escape the next line from the tcl interpreter
exec hcitcl “$0” “$@”
global HciConnName
set HciConnName gen_smat_ai_gen_rcv
proc msgget {aId {aAction NONE}} {
global gMsg
if {$aAction == “S”} {
set gMsg $aId
return
}
return $gMsg
}
set myMsg {MSH|^~&|HL7LAB||CLOVERLEAF|qdxi01p|200510131611||ORU^R01|4139137|D|2.1|||||^MPID|||A9994292||A^A||19850108|M|||A^^F|||||||||||^MPV1||O|INFD||||||||||||||||$myAcct||||||||||||||||||||||||||
|||||^MOBR|1||11|MSYPH^SYPHILUS^L||200510181408|200510181359|||||||200510181408||034020CW^M&L|||$myReq@OBR19|FTH^|112703C|200510131611||$myPerf@OBR24|F|||||||||||^MOBX|1|FT|Y29JSY^^L|| TEST RESULTS|||
|||F|||||^M}
foreach myAcct {FH@123456789012 F123 AA@123456789012 {} } {
foreach myReq {FH AA XX X {}} {
foreach myPerf {FH AA XX X {}} {
echo “Acct >$myAcct<" echo “Req >$myReq<" echo “Perf >$myPerf<" msgget “[subst -nobackslashes -nocommands $myMsg]” S echo “tReturn [ris_code_trx_id 1]” } } } exit