Announcement

Collapse
No announcement yet.

Catch an event when a file reader source begins to read a file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Catch an event when a file reader source begins to read a file

    I'm doing a channel with a File Reader at source and a Database Writer at destination.
    The file is a delimited one (using | as column delimiter and \n as a record delimiter)
    The file contains about 400 records (the hospital census)
    the channel polls for a new file every 15 minutes and "Process Batch files" are checked to "yes"

    I want to put all this records in a Database table.

    Till here, it seems an easy task to do with Mirth.
    But, I want to perform some actions in the database table (if fact, delete all the previous records) when a new file is starting to be processed before putting records on it.

    I wonder if exists an event in Mirth that can be triggered when a file is readed or begins to be readed that I could use to perform these actions.

    thanks a lot.

    carles massallé

  • #2
    This is interesting, but a bit tricky. so, each time a new file is picked up, you want to truncate the database table?

    I'd create two channels. Channel A picks up and reads in the entire content of the file, and re-routes it to another Channel B that processes the batch. You'll create a step in the Channel A that truncates the database table before the batch data is sent to Channel B.

    That's just how I'd do it. Someone else may have a completely different approach.
    Chris Ro
    Sr. Software Engineer | Mirth Corporation

    Comment


    • #3
      In fact, each time a new file is picked up (before start processing rows), I want to delete all the records on the destination table.

      I'm now trying to do this with two channels, as you suggested.

      I'll post here my advances.

      thanks.

      carles.

      Comment


      • #4
        Finally, I've done it.

        As I promised, I've attached with this post these two channels if they could be useful for someone.

        Summary:
        The target is feed the hospital kitchen software with current hospital census. Census are provided by HIS with a delimited file which is updated periodically.
        Before insert file rows in the census kitchen database table I have to delete all previous table records.

        Channel Descriptions:
        - "CensCuinaFitxer":
        This channel retrieves the entire content of the file in a single message (by setting "Process batch files as 'no'"). It has 3 destinations:
        -- "GuardarFitxerDeCens": This destination only saves the file in other place for backup purposes.
        -- "EsborraLaTaulaDeCens": This destination deletes all the content of census table before I fill it again.
        -- "PartirElFitxerEnMissatges": A JavaScript transformer step on this destination splits the incoming file in messages and send them to "CensCuinaLinea" channel.

        var i=0;
        while (msg['row'][i] != null) {
        router.routeMessage('CensCuinaLinea',msg['row'][i].toString());
        i=i+1;
        }

        "CensCuinalLinea":
        This channel process every row sent by "CensCuinaFitxer" individualy.

        thanks chrisr for your useful suggestions.

        carles.
        Attached Files
        Last edited by carles; 05-04-2009, 01:34 AM. Reason: minor corrections

        Comment

        Working...
        X