Announcement

Collapse
No announcement yet.

PDF Template help for Newbie

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

  • PDF Template help for Newbie

    My 1st Post to a Mirth Forum.
    RN working with EMR / HIE last 7 years. (Nice change.)

    Learned Javascript while building 2 hospital interfaces w/ Mirth.
    (Awesome Interface Engine!)

    Is there a sample template (very simple is fine) for Document Writer->PDF?

    I realize it involves HTML. Just need an example, even for one data item (i.e MedicalRecordNumber).

    Thanks in advance for any help!
    Rod Sellers
    "Psalm 34:3"

  • #2
    Rod, a basic HTML page with substituted channel variables would work. Suppose you had mapped the medical record number in a transformer step, then named that variable medicalRecordNumber, you could use the following HTML in the document writer template:

    <table>
    <tr>
    <td>Medical Record Number:</td>
    </tr>
    <tr>
    <td>${medicalRecordNumber}</td>
    </tr>
    </table>

    This HTML would create a simple one-row, two-column table, with the text "Medical Record Number" in the first column, and the value for the medical record number extracted from the message (assuming you created a transformation using either a Mapper to extract the value and set a channel variable, or a JavaScript using channelMap.put).

    Hope that helps!

    Phil

    Comment


    • #3
      Thanks! One more question...

      Thanks Phil! Worked Great.

      I've tried to add an image, i.e. simulate a Lab's logo at the top of the page.

      I use the <img src=".../> html, but it doesn't show up.

      Any ideas?

      - Rod
      Rod Sellers
      "Psalm 34:3"

      Comment


      • #4
        In the src attribute, try using a absolute reference to the file.

        Comment


        • #5
          As an example, we have a Mirth channel (server is Windows) that creates some PDF letters with data pulled from a database.

          There is a logo included on the logo that lives in the C:\graphics\ folder on the server running Mirth. In the template:

          <img src="/graphics/c_logo.jpg" />

          Makes the image appear.

          Comment


          • #6
            Awesome Community Support!

            Thanks for the quick and expert assistance. Worked wonderfully.

            I also used CSS (1st time) to get the image to center at the top of the PDF. *It's nice to still learn "new" things in one's mid-life.

            - Rod
            Rod Sellers
            "Psalm 34:3"

            Comment


            • #7
              Loop in pdf template

              Any one knows how to loop through OBX segments in a pdf template?. I am using Mirth version 2.2.1. My destination is Document Writer and source is file reader. I am stuck on the middle way as I am not aware of how to loop through an OBX segment in a pdf template.

              Comment


              • #8
                Originally posted by biju16mvk View Post
                Any one knows how to loop through OBX segments in a pdf template?. I am using Mirth version 2.2.1. My destination is Document Writer and source is file reader. I am stuck on the middle way as I am not aware of how to loop through an OBX segment in a pdf template.
                You can create some array of things to iterate through in your transformer:

                Code:
                var observations = [];
                for each (obx in msg.OBX)
                	observations.push(obx['OBX.5']['OBX.5.1'].toString());
                $co('observations',observations);
                And then display each element in the Velocity template:

                Code:
                #foreach($obs in $observations)$obs#end
                It can get much more complex than that too. You can pass custom multifaceted objects into the context and do whatever you want with them.
                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


                • #9
                  OBX.5 transformer

                  Code:
                  var DocumentText = "";
                  for each (documentLine in msg['OBX']['OBX.5']['OBX.5.1'])
                  {
                  	DocumentText += "<br/>" + documentLine;
                  }
                  connectorMap.put('DocumentText', DocumentText);
                  In your PDF template put:

                  Code:
                  	<p><span><BR/>
                  	${DocumentText}<BR/>
                  	</span></p>

                  Comment

                  Working...
                  X