Upoc Read Write script for HL7 batch file

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Upoc Read Write script for HL7 batch file

  • Creator
    Topic
  • #50286
    Bill Pitts
    Participant

      Hello,

      I have the need to batch some HL7 results msgs.

      I have a tps script that does some slight reformatting of the source transactions.

      These are passed to an outbound thread, Upoc Protocol, that puts the headers/trailers on the input via another tps tcl applied to both read/write steps.

      The output batches are created fine and include the header and trailer lines but I’m getting errors in my Error db with the message:

      ” Disposition list from protocol write TPS did not include original message”

      Attached is the code

      I’m sure it’s something simple that I’m missing.

      Thanks for your input

      Bill Pitts

      Perot Systems

    Viewing 2 reply threads
    • Author
      Replies
      • #65475
        Bill Pitts
        Participant

          Sorry,

          Upload of tcl didn’t format well

          Code to format HL7 batch is below

          Thanks

          Bill

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

          # Name: tpsMDPHtest

          # Purpose: Batch Header & Trailer and Output File for Cerner Results to MDPH ELR  

          #              

          #

          #

          #

          #            

          # 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:

          #          

          #

          #

          #

          #    *********************************************************************

          #    on RUN mode:    Appends msgs to temp file TUFTS_MDPH_ELR_tmp_in.txt

          #

          #                    Make sure to set Process name to “cerner” for TEST/PROD

          #

          #    on TIMER mode:  Writes header, reads/write msgs from temp file to

          #                    TUFTS_MDPH_ELR_OUT.yyyymmddhhmm file, writes trailer

          #

          #                    Deletes .tmp file upon completion

          #

          #    ***********************************************************************

          #

          #


          # Modifications:

          #

          #  date   init     mod desc

          #

          #  

          #


          proc tpsMDPHtest { args } {

                       

             keylget args MODE mode   ;# Fetch mod

             set dispList {} ;# Nothing to return

             

             #Make sure to set Process name to “cerner” for TEST/PROD

             #set Process “cerner”

             set Process “testing”

             set Outpath “/mdph_to_send/”

             

           

             switch -exact — $mode {

                 start {

                     # startup stuff

             # 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 msg [msgget $mh]

                         

                         

                     # Get rid of all x1c and x0b

                         regsub -all — {[x1cx0b]} $msg {} msg

                     

                         

                     #Get the time in system seconds

                         set systemTime [clock seconds]

                     #Set the time using the hour, minute and second descriptors.

                         set CurDate [clock format $systemTime -format {%Y%m%d}]

                         set CurDateTime [clock format $systemTime -format {%Y%m%d%H%M}]

                      # set directory path

                      set root_path [exec env HCIROOT]

                      set site_path [exec env HCISITEDIR]

                      set subdir “exec/processes/$Process”

                      append site_path “/$subdir/”

                       

                     

                     # set the user data… for the message

                        set filename “TUFTS_MDPH_ELR_tmp”

                        set filenameextension “txt”

                        set fullname $site_path$filename.$filenameextension

                         

                     # open tmp file, write record

                        set curFileID [open $fullname a]

                        puts -nonewline $curFileID $msgr

               

                     # close tmp File

                       close $curFileID

                     # return message

                      lappend $dispList {CONTINUE “$mh”}

                      return $dispList

                       

                    }

                           

                time {

                     # Timer-based processing

             # N.B.: there may or may not be a MSGID key in args

                       

                     

                       # Build envelope

                       set cloverclock [clock format [clock second] -format %Y%m%d%H%M%S]

                       set fhs “FHS|^~\&|Cerner Lab|TUFTS|ELR|MDPH|$cloverclock||$cloverclock|||r”

                       set bhs “BHS|^~\&|Cerner Lab|TUFTS|ELR|MDPH|$cloverclock||$cloverclock|||r”

                       

                       # set file header

                        set fileheader $fhs$bhs

                       

                      # set directory path

                      set root_path [exec env HCIROOT]

                      set site_path [exec env HCISITEDIR]

                      set subdir “exec/processes/$Process”

                      append site_path “/$subdir/”

                       

                   

                     #Get the time in system seconds

                         set systemTime [clock seconds]

                     #Set the time using the hour, minute and second descriptors.

                         set CurDate [clock format $systemTime -format {%Y%m%d}]

                         set CurDateTime [clock format $systemTime -format {%Y%m%d%H%M}]

                   

                     # input file parameters

                     # set the user data… for the message

                        set filein “TUFTS_MDPH_ELR_tmp”  

                        set fileInExt “txt”

                        set fullnameIn $site_path$filein.$fileInExt

                       

                     # set output path and filename

                     # NOTE: “mdph_to_send” defined as Outpath, from beginning of proc

                        set sub_path_out $Outpath

                        append site_path $sub_path_out

                        set fileout “TUFTS_MDPH_ELR_OUT”

                        set fileoutExt  $CurDateTime

                       

                        set outFile $site_path$fileout.$fileoutExt

                           

                   

                     # get input

                     set tempfileFlagIn [file exists $fullnameIn]

                     if {$tempfileFlagIn == 1} {

                           set outFileID [open $outFile a+]

                           # write header

                           puts -nonewline $outFileID $fileheader

                           set inFileID [open $fullnameIn r]

                           set wholefile1 [read $inFileID]

                   

                     #

                     # split the file into its transactions

                     # remove any blank transactions (extra newlines)

                   

                           set BatchTrnxCount 0

                               foreach BatchRec [split $wholefile1 “n”] {

                                   if {[clength $BatchRec] == 0} {

                            continue

                         } else {

                                       puts -nonewline $outFileID $BatchRec

                                       set BatchTrnxCount [regexp -all {MSH} $BatchRec]

                                   }

                               }

                     

                      # set file TRAILER

                          set bts “BTS|$BatchTrnxCount|r”

                          set fts “FTS|1|r”

                          set filetrailer $bts$fts

                     

                      ### Write TRAILER

                   

                          set EOFcurr [eof $inFileID]

                              if {$EOFcurr == 1} {

                                   puts -nonewline $outFileID $filetrailer

                                   close $outFileID      

                              }

                     

                          close $inFileID

                          # delete tmp Input file

                          file delete $fullnameIn

                      }

                     

                   

                }

               

               

           }

               

            ###return $dispList

          }

        • #65476
          Tom Rioux
          Participant

            Bill,

            I’m not sure if this is your issue, but your lappend for your dispList looks a little different than the way we do it here.  It might now mean anything, but we set ours like this:

            lappend dispList “CONTINUE $mh”

            Give it a shot..

            Tom Rioux

            Baylor Health Care

          • #65477
            Mike Grieger
            Participant

              Looks to me as though your timer mode isn’t dealing with the message dispList.  So, if all you need to have done in that timer mode is to deal with you files, you would still want to have a return of your dispList – KILL the message handle if you don’t need the message going anywhere.

              At least, that’s my guess from taking a quick look.

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