› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Output HL7 to file with unique file names
c:results111111.txt
c:resultsyyyyyy.txt
where yyyyyy = number given within the HL7 message, like ORC.2 (accession number)? Sounds like TCL is needed. Thanks.
In your outbound thread, add a tps where you can change the file name through driverctl. After you retrieve your field “orc2” from the message you can add something like this:
set outfile $orc2.txt
set driverctl “{FILESET {{OBFILE $outfile}}}”
msgmetaset $mh DRIVERCTL $driverctl
Then continue the msg.
This is just the part of the script that I thought showed what you where looking for, I removed all the field manipulation that I had to do to the message before writing it back out.
Let me know if you have any questions. I hope it helps.
######################################################################
# Name: cvu_a08_resend
# Purpose: Write all trans to files
# UPoC type: tps
# 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:
#
#
proc cvu_a08_resend { args } {
keylget args MODE mode ;# Fetch mode
set dispList {} ;# Nothing to return
set datList [datlist]
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 mh
set message [msgget $mh]
set pwd /hci/cvudata
#### GET ACCOUNT NUMBER FROM HL7 MESSAGE ####
set gh [grmcreate -msg $mh hl7 2.1 cvu ADT_A08]
set dh [grmfetch $gh {0(0).PID.00035.[0]}]
set val [datget $dh VALUE]
if [file exists $pwd/$val.ctl] {
file delete $pwd/$val.dat
set ch [open $pwd/$val.dat w]
puts $ch $message
close $ch
} else {
set ch1 [open $pwd/$val.ctl w]
set timestamp [exec date]
puts $ch1 $timestamp
close $ch1
set ch2 [open $pwd/$val.dat w]
puts $ch2 $message
close $ch2
}
lappend dispList “CONTINUE $mh”
grmdestroy $gh
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
}
}
hcidatlistreset $datList
return $dispList
}
Craig Weldy
Senior Interface Analyst
Beacon Health System
South Bend, In, 46615
Action: COPY
Input: ORC;2 (or whatever field you want to use for your filename)
Output: @null
TCL-Pre: xpmmetaset $xlateId DRIVERCTL “{FILESET {{OBFILE [lindex $xlateInVals 0]}}}”
set driverctl “{FILESET {{OBFILE $outfile}}}”
msgmetaset $mh DRIVERCTL $driverctl
Then continue the msg.
Which protocol do you suggest using with this? I’ve attempted using local ftp and also file. I can’t seem to get any output. Mostly I get an error that the file can’t be opened. I’m receiving the HL7 messages through tcpip and need to output them to a folder each neatly in their own individual file.
Which protocol do you suggest using with this?
I’d use ‘fileset-local’. That way you can specify a unique filename for each file in the DRIVERCTL.
I have also tried the file protocol and have had the best result with “default.dat” in the Filename field and the append checkbox unchecked in the Outbound section of the protocol properties pop-up and with my tclproc is in the TPS Outbound Data field on the Outbound tab. However, even though in the log, I can see where my file name is created and there is a message that says that DRIVERCTL is being parsed, immediately afterward it writes/appends the message to “default.dat”.
This is very frustrating as it is clearly the wrong behavior from what I’m expecting. All of these examples and fileset_numout have been great, but none of them have offered any suggestion as to how they’ve been utilized inside Cloverleaf, which is I suppose where I’ve gone astray.