Announcement

Collapse
No announcement yet.

Batch processing edi 834 files

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

  • Batch processing edi 834 files

    I am trying to parse a huge EDI 834 file which come in one single line to be split into different messages whenever the segment 'INS' is encountered.
    Does anyone have sample javascript code they are willing to share?

  • #2
    Can't you split the string on 'INS'?

    http://www.w3schools.com/js/js_string_methods.asp

    txt.split("INS");
    Last edited by appsbyaaron; 11-09-2016, 11:40 AM.

    Comment


    • #3
      Thanks. I did try that. I am probably missing something but it only returns the string before the first encountered 'INS'. I need it to keep looing through the line and return messages each time it encounters 'INS'.

      This is the code I have right now:

      var line="";
      var message="";

      if (reader.read() != -1) {
      while (line = reader.readLine())
      {
      message = line.split("INS");
      for (i = 0; i < message.length; i++){
      return message[i];
      }
      break;
      }


      //return message;
      }
      else
      return '';

      What am I missing here?
      Than you again for responding.

      Comment


      • #4
        I have attached the test channel.
        I am just trying to figure out the javascript code for split by batch

        Thanks
        Attached Files

        Comment


        • #5
          Does anyone have any suggestions? I am currently stuck on this.

          Thanks

          Comment


          • #6
            I posted this on the public Slack channel. Should provide a good starting point.
            Attached Files
            Last edited by narupley; 05-16-2018, 08:24 AM.
            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment


            • #7
              Originally posted by narupley View Post
              I posted this on the public Slack channel: EDI/X12 Batch Script

              Should provide a good starting point.
              I am working on a similar use case and used the script provided on Slack. The channel is taking a lot of time to process just one message and after a while, I see a java heap space error. Any help is appreciated.

              Comment


              • #8
                Can you show how you are calling/using the script?
                HL7v2.7 Certified Control Specialist!

                Comment


                • #9
                  Originally posted by siddharth View Post
                  Can you show how you are calling/using the script?
                  I changed the data types to raw and under batch, I have used the script provided by Nick and on the source, I selected process batch. It's a huge file close to 70MB. Any thoughts!

                  Comment


                  • #10
                    I did something similar for an X12 file. I set "Process Batch" to yes on the summary tab, then configured the "Batch Delimiter" in "Set Data Types".
                    Best,

                    Kirby

                    Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

                    Appliance Version 3.11.4
                    Mirth Connect Version 3.8.0
                    Java Version 1.6.0_45-b06
                    Java (64 bit) Version 1.6.0_45-b06
                    Java 7 (64 bit) Version 1.7.0_151-b15
                    Java 8 (64 bit) Version 1.8.0_181-b13
                    PostgreSQL Version 9.6.8

                    Comment


                    • #11
                      Originally posted by kirbykn2 View Post
                      I did something similar for an X12 file. I set "Process Batch" to yes on the summary tab, then configured the "Batch Delimiter" in "Set Data Types".

                      I have similar set up with following code in batch script and it takes ages to run and it spits out just one message and after that I see heapspace error

                      var segDelim = '~';
                      var elementDelim = '*';
                      var subelementDelim = ':';
                      var infer = true;

                      var message = new java.lang.StringBuilder();
                      var ch;
                      while ((ch = consume(1)) != null) {
                      if (infer) {
                      elementDelim = consume(3);
                      subelementDelim = consume(101);
                      segDelim = consume(1);
                      consumeNewline();
                      infer = false;
                      continue;
                      } else if (ch == segDelim) {
                      consumeNewline();
                      reader.mark(3);
                      if (readChar() == 'I' && readChar() == 'N' && readChar() == 'S') {
                      reader.reset();
                      break;
                      }
                      reader.reset();
                      }
                      }

                      return message.toString();

                      function readChar() {
                      var c = reader.read();
                      return c == -1 ? null : java.lang.Character.valueOf(c);
                      }

                      function consume(num) {
                      var ch;
                      for (var i = 1; i <= num; i++) {
                      ch = readChar();
                      if (ch != null) {
                      message.append(ch);
                      }
                      }
                      return ch;
                      }

                      function consumeNewline() {
                      reader.mark(1);
                      var ch = readChar();
                      if (ch == '\r') {
                      message.append(ch);
                      reader.mark(1);
                      if ((ch = readChar()) == '\n') {
                      message.append(ch);
                      } else {
                      reader.reset();
                      }
                      } else if (ch == '\n') {
                      message.append(ch);
                      } else {
                      reader.reset();
                      }
                      }

                      Comment


                      • #12
                        The script in Split Batch By JavaScript should be as simple as this. Set data type to "Raw".
                        Code:
                        var line = '';
                        var message = '';
                        var array;
                        var header;
                        
                        while (line = reader.readLine()) {
                            header = line.substring(0, line.indexOf('~INS')) + '~\n';
                            array = line.split('~');
                            for (var i in array) {
                                if (array[i].substring(0, 3) == 'INS') {
                                    message += '---\n' + header + array[i] + '~\n';
                                } else {
                                    message += array[i] + '~\n';
                                }
                            }
                        }
                        
                        return message;
                        PS: The "---\n" is only to separate each INS group. You can take that out if you wish.

                        Comment


                        • #13
                          DragonQueen,

                          Can you elaborate on what your channel is supposed to be doing?
                          I imported into my Mirth Connect environment, but all I see is seven lines of source transformer message building things.

                          Where is the reference to the batch processing?

                          Thank you.

                          Comment

                          Working...
                          X