Batch File Processing

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Batch File Processing

  • Creator
  • #50170

    Is anyone out there familiar with setting Cloverleaf up to process a batch file?  I have charge batches with a repeating message body enveloped by BHS and BTS segments.  I’m trying to create a variant that has the structure, but that is not working.  There are some Cloverleaf files off the root directory that implied that the message file could contain a type of hl7batch, but when the variant or xlt file loads it errors out saying that a msg file type was expected.

    Can anyone help me set this up?  Also, is anyone aware of a maximum batch file size?


Viewing 5 reply threads
  • Author
    • #65090
      Mark Thompson


      Check out

      The trick is to remove the batch header and trailer, then split the remainder into into individual HL7 messages.  If you want to get really fancy, you can check the message count on the BTS segment to make sure it matches the number of messages created.

      - Mark Thompson

    • #65091

      Thanks, Mark.

      I think I’ve come to realize (unfortunately) that you’re right.  Well, at least now I’ve got a direction!

    • #65092
      Russ Ross

      I have mucho experience with processing batch files and with cloverleaf which you are learning the two are partially allregic to each other.

      I architected a model that we have used for many years to process all batch type files that has been successfull and well embraced.

      In other words I’m a bit proud of it; however, it is beyond the scope of what I’m willing to post.

      I feel your pain as I remember my past and would be willing to talk by phone to see if I can effectively help you without getting so involved it feels like a second job.

      For the most part I ended up using cloverleaf for what it does well (Xlate) and used stand alone argument driven scripts for everything else even the FTP file movement.

      Russ Ross

    • #65093
      Charlie Bursell

      A pretty simple proc will suffice.  Assume a batch file of the form:

          FHS BHS MSH….. MSH…. BTS FTS

      Strip off and save the header/trailers for inspection, etc.  Get the HL7 messages and send one at a time through the engine.

      Modify to fit specific needs    

      run {

                # Get the IB message as a list

                 keylget args MSGID mh

         # Get msg and remove CR if any

         set ib [string map {r “”} [msgget $mh]]

         # Make it a list

         set ibMsg [split $ib n]

         # Always KILL original

         set dispList

           # just in case make sure variables are set

           set FHS “”; set BHS “”; set BTS “”; set FTS “”

           # Remove and save headers and trailers

           foreach  var {FHS BHS BTS FTS} {

        set loc [lsearch -regexp $ibMsg “^$var”]

        if {$loc >= 0 } { set $var [lvarpop ibMsg $loc] }


           # The list now contains only MSH … etc

           # Make all LF = CR

           set ibMsg [join $ibMsg r]

           # Put a new-line between each message

           regsub -all — {rMSH} $ibMsg “rnMSH” ibMsg

           # Simply step through each and build HL7 message

           foreach msg [split $ibMsg n] {

        # Make sure there is only a single CR after last

                                       # segment

        set msg “[string trimright $msg r]r”

        # New message

        set nmh [msgcopy $mh]

        # Put new message

        msgset $nmh $msg

        # Put in disposition list

        lappend dispList “CONTINUE $nmh”


           # Send it through the engine

           return $dispList


    • #65094


      Great code!  Is this done in the Inbound TPS rather than as a pre-proc to the translation?

    • #65095
      Charlie Bursell

      Pre proc or route proc

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

Forum Statistics

Registered Users
Topic Tags