breaking up batch text file to individual messages proc

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf breaking up batch text file to individual messages proc

  • Creator
    Topic
  • #54631
    Stevie Jamin
    Participant

      Need a proc to separate messages in a text file to send individually as HL7 messages.

    Viewing 8 reply threads
    • Author
      Replies
      • #82320

        If there is one HL7 message per line, then you can use the file/fileset-local protocol to read in each line as a message.

        -- Max Drown (Infor)

      • #82321
        Stevie Jamin
        Participant

          Hi Max.  Thank you for your reply.  I have a text file with a lot of messages.  Each message has an MSH, PID, OBR, and OBX segments.  The receiving system cannot accept one large message with multiple MSH segments, so I need to send it as individual hl7 messages.  I attached a sample of what the file looks like.  Is there something that can be hard coded in the txt file that Cloverleaf knows to separate each message?

        • #82322
          Jim Kosloskey
          Participant

            This will depend on how each segment/line and each message is terminated in the file.

            If the file follows the HL/7 standard with hex 0d ending each segment and 0d0a ending each message then the default settings on the fileset protocol should work.

            So using somethiing like hcihd from the command line get a hex dump of the file and figure out what the terminating characters are.

            If they are not as descriibed as above, let us know. In some cases Tcl may be required.

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

          • #82323

            Here’s a script that will split your file into messages. Set your protocol to read in the entire file (EOF). Place the proc into Inbound TPS. Test it well.

            proc tps_fileset_split_file { args } {
            [code]proc tps_fileset_split_file { args } {

            -- Max Drown (Infor)

          • #82324
            Stevie Jamin
            Participant

              Thanks guys.  I will test the proc this afternoon.

            • #82325
              David Barr
              Participant

                Max Drown wrote:

                Code:

                regsub -all {rMSH|} $file “nMSH|” file

                This should probably be

                Code:

                regsub -all {rMSH|} $file “rnMSH|” file

                There’s supposed to be a CR at the end of the last segment.

              • #82326

                Good catch. That change will preserve the trailing carriage return on the last segment.

                -- Max Drown (Infor)

              • #82327

                Someone replied with another fix, but then deleted it. But, they were correct.

                Code:

                               msgset $mh $msg

                -- Max Drown (Infor)

              • #82328

                Results from my test (the forum software auto replaces the carriage returns):

                Code:

                MSH|^~&|HNAM|ABC|VISICU||20150331132543||ORU^R01|20150331132543|D|2.2
                PID|||74002357^^^&ABCD&^^&ABC&|||||||||||||||74002357
                OBR|||||||20150329132543|||||||||
                OBX|1|ST|BLDPRSYS^BLOOD PRESURE SYSTOLIC^ABC||124|||||||||20150330134311

                MSH|^~&|HNAM|ABC|VISICU||20150331132543||ORU^R01|20150331132543|D|2.2
                PID|||74002357^^^&ABCD&^^&ABC&|||||||||||||||74002357
                OBR|||||||20150329132543|||||||||
                OBX|1|ST|HRTRATE^HEART RATE^ABC||80|||||||||20150330134307

                MSH|^~&|HNAM|ABC|VISICU||20150331132543||ORU^R01|20150331132543|D|2.2
                PID|||74002357^^^&ABCD&^^&ABC&|||||||||||||||74002357
                OBR|||||||20150329132543|||||||||
                OBX|1|ST|RESPR^RESPIRATORY RATE^ABC||18|||||||||20150330134318

                MSH|^~&|HNAM|ABC|VISICU||20150331132543||ORU^R01|20150331132543|D|2.2
                PID|||74002394^^^&ABCD&^^&ABC&|||||||||||||||74002394
                OBR|||||||20150329132543|||||||||
                OBX|1|ST|BLDPRSYS^BLOOD PRESURE SYSTOLIC^ABC||124|||||||||20150330122020

                MSH|^~&|HNAM|ABC|VISICU||20150331132543||ORU^R01|20150331132543|D|2.2
                PID|||74002394^^^&ABCD&^^&ABC&|||||||||||||||74002394
                OBR|||||||20150329132543|||||||||
                OBX|1|ST|HRTRATE^HEART RATE^ABC||80|||||||||20150330122015

                MSH|^~&|HNAM|ABC|VISICU||20150331132543||ORU^R01|20150331132543|D|2.2
                PID|||74002394^^^&ABCD&^^&ABC&|||||||||||||||74002394
                OBR|||||||20150329132543|||||||||
                OBX|1|ST|RESPR^RESPIRATORY RATE^ABC||18|||||||||20150330122030

                -- Max Drown (Infor)

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