Output HL7 to file with unique file names

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Output HL7 to file with unique file names

  • Creator
    Topic
  • #50036
    Thomas Su
    Participant

      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.

    Viewing 6 reply threads
    • Author
      Replies
      • #64636
        Belaid Akharaze
        Participant

          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.

        • #64637
          Craig Weldy
          Participant

            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

          • #64638
            James Nelson
            Participant

              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]}}}”

            • #64639
              Jennifer Hardesty
              Participant

                Belaid 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.

              • #64640
                James Nelson
                Participant

                  Quote:

                  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.

                • #64641
                  Jennifer Hardesty
                  Participant

                    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.

                  • #64642
                    David Burks
                    Participant

                      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?

                  Viewing 6 reply threads
                  • The forum ‘Cloverleaf’ is closed to new topics and replies.