Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCL Script/HL7 related

Status
Not open for further replies.

jidone

Programmer
Mar 5, 2002
5
CA
We are trying to write a proc that will basically look at one of the HL7 fields, it is field that contains an unique ID for each radiology result.

open up a file that resides on the server, scan through it based on a search on the unique ID, and then close it.

If the ID exists within the file, the data is already there, so do not write to the file, and then close it.
If the ID doesn't exist, write to the file and close it.
Also have this file deleted every 24 hours , and then recreate the same file only empty
 
This is all pretty standard file manipulation. To get started, I suggest that you read the replies to "How to create a text file using Tcl/Tk?", thread287-222803, and follow the links provided there.

As for scanning for the particular ID, that depends a lot on the format of the data. You'll probably end up using one of the following Tcl commands, listed in increasing order or power and complexity: string first, string match, scan, or regexp.

And in Tcl, all time and date related information is handled by the clock command.

To get more information about these commands and how to use them, I recommend searching the Tcl'ers Wiki, a collaboratively-edited collection of Tcl wisdom, at
Before I sign off, one idea I had is that if the file isn't too large, you might be able to take care of the scanning and updating with the following (untested):

Code:
# Assume the variable "file" contains the
# name of the log file.

# Opening the file in "a+" mode allows us to
# read from and write to the file. All
# writes are automatically appended to the
# end of the file.

set fid [open $file a+]

# Set the pointer to the beginning of the
# file, because opening the file in any "a"
# mode sets the pointer initially to the end
# of the file.

seek $fid 0

# Read the entire contents of the file

set text [read $fid [file size $file]]

# Assume the variable "id" contains your
# magic ID string.

if {[string first $id $text] == -1} {

  # We didn't find the id in the file.

  # Assume that the variable "record"
  # contains the record we need to write.
  # Write it to the end of the log file.

  puts $fid $record
}

# Close the log file

close $fid
- Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top