TCL proc to read specific file names?

Homepage Clovertech Forums Read Only Archives Cloverleaf Tcl Library TCL proc to read specific file names?

  • Creator
    Topic
  • #55566
    raj golawar
    Participant

    HI folks, still very new to TCL

    On CL6.2, I am using a fileset-ftp protocol to pickup files from a remote folder. The files dropped in that folder by our EMR are by name Patient_* and Provider_*

    I am looking for a script that would read that folder and only pickup the Patient_* files as they arrive.

    Any suggestions?

    Thanks!

Viewing 3 reply threads
  • Author
    Replies
    • #85776
      Jim Kosloskey
      Participant

      You can write a dirparse proc.

      In the Fileset protocol configuration there is an opportunity to invoke a Tcl proc after the protocol collects the name of the files found in the specified directory but prior to processing them.

      Your proc would receive the list of files as a Tcl list (there are some other considerations if you want a list of files with attributes). You can then modify that list and return only those file names (as a list) which you want Cloverleaf to process.

      I have a dirparse proc and a delete proc (for the File Deletion UPoC of the Fileset Protocol) and a package used by both procs to actually manipulate the lists.

      If you want them and their user doc and you know how to build a pkgIndex email me and I will send them to you.

      They are argument driven and could very well accomplish what you need without any modification.

      email: jim.kosloskey@jim-kosloskey.com

    • #85777
      Charlie Bursell
      Participant

      Look at $HCIROOT/contrib/fileset_dir_parse.tcl  for an example

    • #85778
      Sterling Jones
      Participant

      Hi Raj,

      What I have configured is I wrote a simple TCL script like this:

      ###################################

      proc ftp_dir_parse_pattern_[SOMETHING HERE]_ib { args } {

         global HciConnName HciSiteDir

         set module “ftp_dir_parse_pattern/$HciConnName”

         keylget args MODE mode

         set dispList {}

         switch -exact — $mode {

             start {}

             run {

                 

                 set uargs {}; keylget args ARGS uargs

                 set debug 1

                 set today [clock format [clock seconds] -format {%Y%m%d}]

                 set pattern “Patient_$today.txt”

                 catch {keylget uargs PATTERN pattern}

                 set outList {}

                 set dispList {}

                 if {$debug} {puts “DEBUG: $module: pattern: $pattern”}

                 

                 keylget args MSGID mh

                 set fileList [msgget $mh]

                 set outList {}

                     

                 foreach fileName $fileList {

                     if {[regexp $pattern $fileName]} {

                         #echo ” FOUND A FILE”

                         if {$debug} {puts “DEBUG: $module: fileName: $fileName”}

                         lappend outList $fileName

                     }

                 }

                 if {$debug} {puts “DEBUG: $module: outList: $outList”}

                 msgset $mh $outList

                 lappend dispList “CONTINUE $mh”

             }

             time {

                  echo ” ################## IN PROC:  TIME MODE ###############################”

                 }

             shutdown {}

             default {}

         }

         return $dispList

      }

      ###################################

      Then, put the newly created tcl in the “Directory Parse:” section of the TPS in the Inbound area. Hope this helps

    • #85779
      raj golawar
      Participant

      Thanks for the prompt help guys, really helped!

      You rock 🙂

Viewing 3 reply threads
  • The forum ‘Tcl Library’ is closed to new topics and replies.

Forum Statistics

Registered Users
4,984
Forums
28
Topics
9,133
Replies
33,745
Topic Tags
253