Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Output HL7 to file with unique file names
- This topic has 7 replies, 6 voices, and was last updated 16 years, 3 months ago by David Burks.
-
CreatorTopic
-
May 14, 2008 at 9:59 pm #50036Thomas SuParticipant
Anyone know how to output a single HL7 message to a file, and give the file a unique name based upon the content of that HL7 message? For example: 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.
-
CreatorTopic
-
AuthorReplies
-
-
May 15, 2008 at 1:16 pm #64636Belaid AkharazeParticipant
Thomas, 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.
-
May 15, 2008 at 7:26 pm #64637Craig WeldyParticipant
Thomas, Here is a portion of a script I use that takes a message, pulls the account number then saves two files, using acct nmber as the base of the file name with the .dat file containing the message and the .ctl file containing the timedate stamp of the message. 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 -
May 23, 2008 at 2:14 pm #64638James NelsonParticipant
I think a proc is overkill for this. In your translate use an action like this: 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]}}}”
-
June 12, 2008 at 1:39 pm #64639Jennifer HardestyParticipantBelaid Akharaze wrote:
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.
-
June 17, 2008 at 7:22 pm #64640James NelsonParticipantQuote:
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.
-
June 17, 2008 at 8:21 pm #64641Jennifer HardestyParticipant
I have tried fileset-local both with and without something in the outbound directory field in the protocol properties pop-up and with “default.dat” as the dummy file name. My tclproc is in the TPS Outbound Data field on the Outbound tab. Both options simply result in errors. 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.
-
June 18, 2008 at 12:06 pm #64642David BurksParticipant
Jennifer, this is really simple once you have done it once. This should take only a few minutes to sort out and get you on track. Why don’t you call in to support and ask for me?
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.