Inbound Process: multiple messages in one file

Homepage Clovertech Forums Cloverleaf Inbound Process: multiple messages in one file

Tagged: 

  • Creator
    Topic
  • #110475
    Matthew Brophy
    Participant

    We’ve done this many times outbound appending msgs to one file. We’ve done this many times using individual messages inbound to a process.

    We have never done multiple messages contained in one file.  Seeking assistance on the best way to tackle this.  The file terminates each message within the file with a FS [file separator].

     

    I assume we would parse a local directory for the file, then on the TPS inbound data invoke a tcl. proc to foreach through the message looking to rebuild each message until it finds a file separator?

    Attachments:
    You must be logged in to view attached files.
Viewing 2 reply threads
  • Author
    Replies
    • #110484
      Jim Kosloskey
      Participant

      First thing I think is you will need to use the ‘single’ style in your Fileset Protocol configuration so that you can parse out the ‘messages’.

      That means you will get the entire file into your Tps proc (might not be desirable with large files) as a single Cloverleaf ‘message’.

      You probably will want to get rid of the BHS segment as it appears to be worthless.

      Also the %EOF% is curious and needs to be ignored.

      To me this is a abomination of an HL/7 batch. If one were to use the BHS segment one should also use the BTS segment at the end of the batch to provide count, etc. No Control ID in the BHS either. So not of any value whatsoever.

      I don’t see the need to get this so whacked out other than it makes it easier to read in a standard file editor. I would think the sending system should be able to be create a file to match the nl or hl7 style of the Fileset protocol.

      But if not – then you will need to use an IB Tps Tcl proc I think to break out the file retrieved as a single Cloverleaf ‘message’ into multiple HL/7 messages using the FS to split on and clean up the BHS and %EOF% as well as the segment and HL/7 message terminators  so that the ‘messages’ presented back to the engine can be routed and potentially Xlated.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #110492
      Charlie Bursell
      Participant

      Try this:  I haven’t had a lot of luck with uploads so I will put it inline as well as upload

      proc doBatch { args } {
      keylget args MODE mode

      switch -exact — $mode {

      start {
      # Nothing specific
      return “”
      }

      run {
      keylget args MSGID mh

      # Get whole file
      set msg [msgget $mh]

      # Always KILL original
      set dispList

        msgset $mh “”

        # Split on <FS>
        set lst [split $msg \x1c]
        # Remove first (BHS) and last (EOF)
        lvarpop lst
        lvarpop lst end

        # Loop through each and create valid HL7
        foreach el $lst {

        # Remove CR if there
        set el [string map

          $el]

          # Trim off any leading/lagging white space
          set el [string trim $el]

          # Change segment seps to CR
          set el [string map

            $el]

            # Make sure last segment ends with CR
            set el “[string trimright $el]\r”

            # Build new message using same metadata
            set nmh [msgcopy $mh]

            # Put HL7 message in
            msgset $mh $el

            # Add to dispList
            lappend dispList “CONTINUE $nmh”
            }

            # Return the list
            return $dispList

            }

            }
            }

            Attachments:
            You must be logged in to view attached files.
          1. #110514
            Matthew Brophy
            Participant

            Thank you, Jim and Charlie. I appreciate the guidance! I’ll report back what we get working.

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.

        Forum Statistics

        Registered Users
        5,117
        Forums
        28
        Topics
        9,292
        Replies
        34,432
        Topic Tags
        286
        Empty Topic Tags
        10