Announcement

Collapse
No announcement yet.

Override Delimiter Character

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

  • Override Delimiter Character

    In the Outbound Message Template, I have the Data Type set to Delimited Text. If I click on Properties, I can input a character for the Column Delimiter (e.g. comma, pipe). If I leave the Column Delimiter field blank, it appears that MIRTH is inputting a default character (comma) in my output .txt file.

    Is there a way I can "override" this behavior, even if it's necessary to use another Data Type for the Outbound Message Template?

    BTW, the desired output will be fixed length data with no delimiters. For example:

    Kirby JWilson Michael JFox

  • #2
    Yep, just set up your outbound Delimited Text protocol settings so that the Column Widths are whatever you want (e.g. "10,10,10"), and that should override the column delimiter and set the columns up as fixed width. To be safe, you could also remove the Column Delimiter, Record Delimiter, Quote Character, and Escape Character fields, and uncheck the Double Quote Escaping, Ignore Carriage Returns, and Split Batch by Record check boxes.
    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


    • #3
      That worked, thanks! One more thing...I can't seem to get a carriage return (i.e. newline) to work. In the Properties for the Delimited Text, I'm putting this value in for the Record Delimiter:

      \n

      Does it make a difference if my output file is .csv or .txt (I'm outputting a .txt)?

      Comment


      • #4
        Have your tried \r? I am not sure but I think in the training slides they used \r.

        Comment


        • #5
          Originally posted by kirbyjwilson View Post
          That worked, thanks! One more thing...I can't seem to get a carriage return (i.e. newline) to work. In the Properties for the Delimited Text, I'm putting this value in for the Record Delimiter:

          \n

          Does it make a difference if my output file is .csv or .txt (I'm outputting a .txt)?
          Did you want a carriage return or a line feed? A carriage return is 0x0D (\r), while a line feed is 0x0A (\n). "Newline" is more or less just an umbrella term; it can mean different things on different systems. Macs usually use carriage returns, Unix usually uses line feeds, and Windows usually uses both (0x0D0A).

          Either \r or \n should work in the output protocol settings. Do you have more than one record being output?
          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


          • #6
            The data does contain more than one record (it should be around 2,000 records).

            I suppose what I really want is a carriage return and a line feed. But I've tried these 3 without any luck:

            \n
            \r
            \r\n

            I've attached the channel xml if someone wouldn't mind taking a look.

            Thanks,

            Kirby
            Attached Files

            Comment


            • #7
              From what I can see, you're only creating a single record in the delimited text XML per message. So, if you have 2,000 rows in your database that you're querying from, that will flow through your channel as 2,000 discrete messages. Of course, if you have your File Writer set to append to the file (which you do), then it should work just fine. The only hitch then is the record delimiter. Apparently, Mirth Connect only pays attention to the very first character in the Record Delimiter field. So if you have \r\n, it will only use \r as the record delimiter. This is probably something that can be improved, or maybe it's there by design.

              In any case, in order to get around this, you can just include anything extra you want in the destination template. Set \r as your Record Delimiter, and then add the following JavaScript step:

              Code:
              $co('LF','\x0A');
              Then, include that variable in your template. It should end up looking like:

              Code:
              ${message.encodedData}${LF}
              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


              • #8
                That worked perfectly, thanks Nick!

                Comment

                Working...
                X