Directory Parse is just another context. If you are setting up a fileset protocol, you have the option to specify a directory parse proc.
We use one to normalize some data that we get in HRL format, that is new-line delimited between segments. It reformats the data into a properly-delimited HL7 message so that Cloverleaf can use it properly.
Basically, a Dir Parse proc is passed a list of file names as the message. You can then open, edit, close those files using TCL file commands. You then pass back a list of files that you want the protocol file to read in.
Here is the top of ‘run’ segment of one dirparse we use. Sorry for the lack of comments, but all it does is read a list of all the files in the inbound directory, opens the file, reads it in, and closes the file. You can then use that data to make new files, overwrite the data in the existing files, etc…
This proc needs the directory the files are in passed as an argument, since it’s not included in the data passed by Cloverleaf.
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
keylget args ARGS inDir
echo “MH is $mh”
set inFileList [msgget $mh]
echo “inFileList is $inFileList”
foreach inboundFile $inFileList {
set inboundDirectoryFile “$inDir$inboundFile”
set currentFileID [open $inboundDirectoryFile r]
set fileContents [read $currentFileID]
close $currentFileID