- This topic has 0 replies, 1 voice, and was last updated 6 years, 7 months ago by .
-
Topic
-
###################################################################### # Name: calculator_pid_7
# Purpose: Calulate DOB to be less than or equal to the Message Transaction up to 180 days(6 months).
# Change this variable x “180” for the maxiunm age.
#
# UPoC type: Pre Xlate
# Args: tps keyedlist containing the following keys:
# MODE run mode (“start”, “run” or “time”)
# MSGID message handle
# ARGS user-supplied arguments:
# #
# Returns: tps disposition list:
# CONTINUE – Message was processed normally – continue into engine.
#
#
proc calculator_pid_7 { args } {
global HciConnName
keylget args MODE mode ;# Fetch mode
keylget args CONTEXT context ;# Fetch context
if { ! [info exists HciConnName] } {
set HciConnName “UNKNOWN_TD”
}
set dispList {} ;# Nothing to return
switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}
run {
keylget args MSGID mh ;# Fetch the MSGID
# Retrieve the Patient Type from the message. PID Segment.
set flag “0”
set x “180”
set msg [msgget $mh] ;# Get the Message Handle
set field_sep [csubstr $msg 3 1] ;# HL7 field separator
set sub_sep [csubstr $msg 4 1]
set rep_sep [csubstr $msg 5 1]
set segmentList [split $msg r]
set segmentcopy [split $msg r]
foreach segment $segmentList {
if {[cequal [crange $segment 0 2] MSH]} {
set fieldList [split $segment $field_sep]
#echo “fieldList = $fieldList”
set dt
0 7]]
echo “Date = $dt”
}
if {[cequal [crange $segment 0 2] PID]} {
set fieldList [split $segment $field_sep]
#echo “fieldList = $fieldList”
set DOB
0 7]]
echo DOB = $DOB
set FDOB [clock scan $DOB]
echo FDOB = $FDOB
set T [clock add $FDOB $x days]
echo T = $T
set U [clock scan $dt]
echo U = $U
if {$U <= $T} { set flag “1” echo flag = $flag } } append outbuf ${segment}r } set outbuf [string trimright $outbuf “r”] set outbuf “$outbufr” msgset $mh $outbuf if {[cequal $flag “1”]} { lappend dispList “CONTINUE $mh” } else { lappend dispList “KILL $mh” } } time { # Timer-based processing # N.B.: there may or may not be a MSGID key in args } shutdown { # nothing to do } default { error “Unknown mode ‘$mode’ in calulate_pid_7” } } return $dispList }
- The forum ‘Tcl Library’ is closed to new topics and replies.