0
나는이 부록이 포함 된 첫 번째 전에 모든 OBX 세그먼트를 제거 다음 코드를는 HL7 메시지에서 모든 OBX 세그먼트를 제거
# This Cloverleaf TPS script removes all OBX segments prior to the first one that contains "ADDENDUM".
# This script also renumbers the OBX segments.
#
# See http://clovertech.healthvision.com/viewtopic.php?t=5953
proc remove_prior_to_addendum {args} {
# set the procedure name
# This is used for error messages
set procname [lindex [info level [info level]] 0]
# bring some common variables into the scope of this proc
global HciSite HciSiteDir HciProcessesDir HciConnName HciRootDir ibdir
# fetch mode
keylget args MODE mode
# keylget args ARGS.ARGNAME argname
switch -exact -- $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}
run {
# 'run' mode always has a MSGID; fetch and process it
keylget args MSGID msgid
# get the message
set msgdata [msgget $msgid]
# does this message have "ADDENDUM"?
if {! [regexp {OBX[^\r]*\|ADDENDUM} $msgdata] } {
# This message does not have an ADDENDUM, so continue the message
return "{CONTINUE $msgid}"
}
# if we get here, we have an ADDENDUM
# get the separators
set segment_sep \r
# process the message
if { [catch {
# commands
# split the message into segments
set segments [split $msgdata $segment_sep]
# find the first OBX with an ADDENDUM
set addendum_index [lsearch -regexp $segments {^OBX[^\r]*\|ADDENDUM}]
# renumber the OBX segments that will remain
set i 1
foreach index [lsearch -all -regexp -start $addendum_index $segments {^OBX}] {
set segment [lindex $segments $index]
set segments [lreplace $segments $index $index [regsub {^OBX\|[0-9]*\|} $segment "OBX|$i|"]]
incr i
}
# now find any OBX segments prior to the ADDENDUM segment
set obx_indexes [lsearch -all -regexp [lrange $segments 0 [expr $addendum_index - 1]] {^OBX}]
# sort the indexes descending so that we can safely remove the indexes
set obx_indexes [lsort -decreasing -integer $obx_indexes]
# remove each segment
foreach index $obx_indexes {
set segments [lreplace $segments $index $index]
}
# rebuild the message
set msgdata [join $segments $segment_sep]
} errmsg ] } {
# the commands errored
global errorInfo
msgmetaset $msgid USERDATA "ERROR: $errmsg\n*** Tcl TRACE ***\n$errorInfo"
# rethrow the error
error $errmsg $errorInfo
}
# set the output message
msgset $msgid $msgdata
# return whether to kill, continue, etc. the message
return "{CONTINUE $msgid}"
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Do some clean-up work
}
default {
error "Unknown mode in $procname: $mode"
return "" ;# Dont know what to do
}
}
}
가 어떻게 그것을 ALL OBX을 제거하도록 스크립트를 수정합니까 메시지의 세그먼트?
은 여러 개의 작은 절차 있도록 내가 그 절차를 리팩토링하는 것이 좋습니다를 각각은 특정 상태를 처리하지만 가능한 경우 마스터 프로 시저에서 오류 처리를 유지합니다. 이 경우에 어떤 일이 일어나는지 파악하는 것이 훨씬 쉽습니다! –
이것은 우리의 새로운 StackExchange IT Healthcare 사이트에 큰 질문이 될 것입니다. Cloverleaf에 대한 질문이 많지 않습니다. http://area51.stackexchange.com/proposals/51758/healthcare-it – ChronoFish
여기에 같은 로그인 정보를 사용할 수 있습니까? 네가 원한다면 내가 거기에서 물어볼거야. – Si8