Announcement

Collapse
No announcement yet.

addAttachment

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

  • addAttachment

    Hi All,

    I have a channel that receives an ORU message that is used for pdf document delivery. The sending app put a filename & path in OBX.5.1. The mirth channel I have written reads in the pdf and embeds this in OBX.5.5.

    The interface works fine but I would like to make sure that I am being efficient in the code. Should I be using addAttachment as well? The msg traverses two channels.. if I used addAttachment would this mean only a single instance of the message is stored?

    P.S. I have queuing enabled & message archiving.

    Rgds,

    Glenn

  • #2
    Need the exact same thing.

    I am trying to do the same thing. I have read multiple posts, but have been unable to accomplish this. Here is a post that I believe he is doing this.

    https://www.mirthcorp.com/community/...ad.php?p=51973
    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


    • #3
      Yes, read in the file as a byte array and use addAttachment to store an attachment for it. Then put the attachment replacement token (look at the Attachment class in the User API) in OBX.5.5.
      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


      • #4
        Nick, Can you provide some example code of what steps you would take?

        What I am trying to do is take a HL7 message in, use the contents in OBX.5 to create a PDF and then send that pdf in OBX.5

        Comment


        • #5
          Originally posted by jadams4 View Post
          Nick, Can you provide some example code of what steps you would take?

          What I am trying to do is take a HL7 message in, use the contents in OBX.5 to create a PDF and then send that pdf in OBX.5
          Look at the auto-completion dialog (screenshot attached) to see how to use that method. It returns an Attachment object, so look at the User API to see what methods you can call on it. After creating the attachment, you will want to get the attachment replacement token and embed it in your HL7 message.
          Attached Files
          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
            var test = AttachmentUtil.getMessageAttachments(connectorMess age);
            attachment = addAttachment(test.toString(), "application/pdf");
            logger.info(attachment);
            var attachmentToken = attachment.getAttachmentId();
            msg['EVN']['EVN.1']['EVN.1.1'] = test;


            This code populates EVN.1.1 with [[email protected] 7d4]

            Am I missing a step?

            Comment


            • #7
              I've attached a channel to illustrate (3.3.0)... you don't even need to use JavaScript for something simple like this.

              Example - Create and Embed PDF in HL7:
              • Destination 1: Create PDF (Document Writer)
                • Output: Attachment
                • Template: "testing"


              • Destination 2: Embed PDF in HL7 Message (Channel Writer)
                • Transformer Step: Put attachment replacement token in EVN.1.1 (Message Builder)
                  • Message Segment: msg['EVN']['EVN.1']['EVN.1.1']
                  • Mapping: $('d1').getMessage()
              Attached Files
              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
                Thanks, that is exactly what I was trying to do. I was focusing on all of the Attachment and AttachmentUtil methods rather than the ImmutableResponse.

                Comment


                • #9
                  How did you find this

                  Nick,

                  I have seen numerous posts in the forum of people struggling to do this. It would help the Mirth community to understand how you arrived at this solution.

                  If this is in the documentation, please post a link as to where we could've figured this out for ourselves.

                  •Destination 2: Embed PDF in HL7 Message (Channel Writer)◦Transformer Step: Put attachment replacement token in EVN.1.1 (Message Builder)◾Message Segment: msg['EVN']['EVN.1']['EVN.1.1']
                  ◾Mapping: $('d1').getMessage()

                  We obviously do not have (and never will have) the in depth knowledge of Mirth that you possess. Mirth is a tool that we use to do a portion of our job. This forum and Mirth support are the only places we can go to ask questions like this.

                  So your clear concise answers are greatly appreciated. As well as any references to the documentation where we may find these answers ourselves.
                  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


                  • #10
                    I'm pretty sure the training documentation references the response map and how it's used, more than once. In order to retrieve something from the response map, do this:

                    Code:
                    responseMap.get('key')
                    Each destination will automatically place its own response in the map, so in subsequent destinations you can do this:

                    Code:
                    responseMap.get('Destination 1')
                    Replace "Destination 1" with the actual name of the destination. Or if you want your code to be correct even if you change the destination name later, use the "d#" key instead, where # is the metadata ID (visible on the destination table itself). Like this:

                    Code:
                    responseMap.get('d1')
                    Of course you didn't have to "just know" that. It's in the documentation for the response map (Click the View User API task in the Administrator, or go here), and in the auto-completion menu:



                    Also, in the transformer of the second destination, you can just drag-and-drop the response from the previous destination. Look at the References tab, and under the "Available Variables" list, previous destinations as well as any channel map variables, etc. will be listed. If you drag-and-drop that entry, you get basically the same thing:

                    Code:
                    $('d1')
                    The "$" is a shorthand method to lookup a variable in all available maps (response / connector / channel / source / global channel / global / configuration). That is covered in the training documentation, and again, it's also available in the auto-completion menu:



                    The Document Writer destination also tells you that the attachment token will be stored as a response map variable:



                    And, it's also in the user guide:





                    Basically, we try to document things as best we can (and granted, it's continually improving). Here are a few tips:
                    • Read tool-tips. On almost any field / radio button / etc., hover your mouse over the component, and the tool-tip should tell you more information about it.
                    • Read the User API. You can get there many different ways:
                      1. Click the "View User API" task in the bottom-left of the Administrator.
                      2. Right-click in any JavaScript context, and select "View User API".
                      3. Use the auto-completion menu to look up a class name (like ChannelUtil), then click on the blue link in the description dialog.
                      4. Navigate directly to your locally hosted javadocs in a browser. For example: http://localhost:8080/javadocs/user-api/
                      5. Visit the User API javadocs hosted on our website: http://javadocs.mirthcorp.com/connect/3.3.0/user-api/
                    • Read the Mirth Connect User Guide. This is meant to be a general use guide, so some parts of it may seem "well duh I knew that already" to you, depending on your experience with Mirth Connect or other similar applications. Still, it serves as a good reference supplement.
                    • Use the auto-completion menu. In any JavaScript text area, press Ctrl+Space to bring it up. You can change that shortcut key in the Administrator settings if you want. You can start typing the name of a class/method/variable and a list of candidate matches will show up. It will also automatically pop-up when you press "." after an identifier (like "ChannelUtil"). You can change that in the Administrator settings as well.


                    Also (and I'm speaking here in general, not just to you Kirby), if you're a support customer then you'll have access to our monthly Developer Q&A webinars. You can always ask whatever questions you want and we'll answer them live. However if you have a specific question or something you'd like us to demonstrate more in-depth, by all means let us know beforehand (e-mail the help desk). That way we'll have time to set something up in advance.
                    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

                    Working...
                    X