Announcement

Collapse
No announcement yet.

File Writer Template New Line or Carriage Return

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

  • File Writer Template New Line or Carriage Return

    I am new to HL7 and new to Mirth. That being said I am very impressed how easy it was to get data through the program. My immediate problem is hopefully a very simple formating question. I'm using the File Writer output option. My template is very simple:

    ${PatientID},${LastName},${FirstName},${MiddleName }

    Unfortunately I get no new line character, line feed, or carriage return after each data line. It all runs together. I tried the double return suggested for the Document Writer option but it did not work. Neither did ^M or any other control or escape codes I could think of. They all dutifuly printed in my output exactly as written. What exactly is the template field and what syntax can I use apart from the provided variables?

    Post edited by: mhorste, at: 01/24/2008 15:08

  • #2
    Re:File Writer Template New Line or Carriage Return

    Try this JavaScript code.

    (Source Tab / Edit Transformer / Right-click / Add a new step / Click on "Type" column header / Select "JavaScript". This is in Mirth v1.5 and it should be similar if you are using a different version).

    Code:
    var patientID = msg['PID']['PID.3']['PID.3.1'].toString();
    var firstName = msg['PID']['PID.5']['PID.5.2'].toString(); 
    var lastName = msg['PID']['PID.5']['PID.5.1'].toString();
    var middleName =  msg['PID']['PID.5']['PID.5.3'].toString();
    
    var patientInfo = patientID + ", " + lastName + ", " + firstName + ", " + middleName + "rn";
    // The forum is messing up the back slash. It is carriage-return and line-feed at the end and it is "back slash r backslash n".
    
    channelMap.put('PatientInformation', patientInfo );
    Destination Tab / File Writer / Template:
    ${PatientInformation}

    Hope this helps!

    Post edited by: nshaik, at: 01/25/2008 07:16

    Comment


    • #3
      Re:File Writer Template New Line or Carriage Return

      Thanks, it worked!
      I was hoping for a shortcut to use in the File Writer Template window. This was a test message. I have a lot more data to extract to a file. The Javascript will work but is cumbersome.

      mhorste

      Comment


      • #4
        Re:File Writer Template New Line or Carriage Return

        Transformer JavaScript Step
        Code:
        var crRetLnFeed = "rn";
        // Backslash r backslash n.
        channelMap.put('CRLF',  crRetLnFeed);
        Destination Template
        ${PatientID},${LastName},${FirstName},${MiddleName }${CRLF}

        Post edited by: nshaik, at: 01/25/2008 19:46

        Comment


        • #5
          Re:File Writer Template New Line or Carriage Retur

          Hi nshaik!

          I got an issue and it looks similar with that you're discusting on this thread.

          I'm running in the source tab a stored procedure using java script. No problem at all!
          My stored procedure is gonna give me a result like SELECT * FROM TABLE_NAME, with maybe 15 fields as result set.

          The question is, how can I capture the result set from the source tab like descibed above, and use it in the destination tab?

          I was using a transformer as javascript type with the code:

          channelMap.put('lastname', result.getString(3));

          It's not working.

          What should I do to make it working?

          Thanks a lot!

          Alexander

          Comment

          Working...
          X