No announcement yet.

Storing the HTML used in a HTML Template in a file

  • Filter
  • Time
  • Show
Clear All
new posts

  • Storing the HTML used in a HTML Template in a file

    I am new to Mirth Connect and this is my first post. I have searched and not found anything that relates to what I am trying to do. I am using Mirth Connect on Windows 10.

    I have a test channel which polls a Windows folder and reads from text files which each contain a single HL7 message. There is a Destination Connector which has a Document Writer set to produce RTF documents.

    When the HTML Template field of the Destination Connector contains the following HTML, it works correctly:

    <h1>My Report Title</h1>
    <h2 style="color: #990000;">${MyVar1}</h2>
    <h3>Second value: ${MyVar2}</h3>

    It produces output like this, as expected:

    My Report Title
    My Value 1
    Second value: My Variable Two

    However, I would like to read the HTML from a file and place it into the HTML Template field. The idea is to have one HTML template which can be used by several destination connectors.

    I have set up some Global Script code to read in the HTML to a string variable:

    var simpleTemplate ='C:\\Mirth Work\\Templates\\SimpleRTFTemplate.html');


    I have created a Transformer Step which creates a channel variable SimpleRTFText like this:


    I have then dragged the channel variable into the HTML Template field to replace the HTML text I had before:


    This will produce an RTF. Unfortunately, it does not evaluate the velocity variables in the string and simply creates an RTF that literally looks like the text read from the HTML file:

    My Report Title
    Second value: ${MyVar2}

    So my question is: How do I get the connector to evaluate the velocity variables within the HTML text string before it creates the RTF?

    It feels like the velocity command #include <myfile> would be cleanest the thing to use, but that does not work. Perhaps there is something besides ${SimpleRTFTemplate} which could be used which force the text to be both inserted and evaluated.

    PS. I do realize that there is a known issue with the conversion and that leading white space is being picked up and included in the output. That is another reason I want to put the HTML in a separate file so that it can be minified first.