Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

How to Initialize TMP?

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

  • How to Initialize TMP?

    Hello,

    Is it possible to initialize "tmp" in a JavaScript Transformer Step without placing anything in the Outbound Message Template?

    Would like to avoid this error: 'ReferenceError: "tmp" is not defined.'

  • #2
    Re:How to Initialize TMP?

    Yes just add the nest JavaScript step:

    Code:
    tmp={};

    Comment


    • #3
      Re:How to Initialize TMP?

      tmp={};
      tmp['MSH']['MSH.1'] = "|";

      TypeError: Cannot set property "MSH.1" of undefined to "|"

      I don't understand the above error. Can you explain it?

      Thank you!

      Comment


      • #4
        Re:How to Initialize TMP?

        I think the more important question is WHY are you trying to use the template variable (tmp) if you don't have a template? If you need to fill in fields, use a template and then overwrite those fields or keep them empty in the template.
        Jacob Brauer
        Director, Software Development
        NextGen Healthcare

        sigpic

        Comment


        • #5
          Re:How to Initialize TMP?

          There's always a reason for someone's madness ha ha

          Mine are as follows:
          i) Trying to create segments from scratch
          ii) Don't want to have a template with empty fields
          iii) Don't want to have a template with complete fields

          I am able to do what I want, by adding "MSH|" in my outbound template, because at least each message I'm creating has a message header. However, I was interested if there was a way I can forgo having to have something in the outbound template, if I can just initialize the template in javascript and create all my segments from scratch.

          For example, what I am trying to avoid is having messages with data from my outbound template, empty or not. So, if I have code to create a msg with only MSH, PID, OCR, OBR, OBX. And, my template has MSH, PID, OCR, OBR, OBX, PV1.... I don't want my message to end up with the PV1 segment.

          I hope you understand what I am trying to achieve, I guess, what I am doing is unconventional. I am just new to Mirth, and thought it would make sense for it to be able to that.

          Comment


          • #6
            Re:How to Initialize TMP?

            Ok.

            It's a common Javascript behaviour:

            Code:
            tmp={};
            tmp['MSH']={};
            //You need to create the parent node before the leaf
            tmp['MSH']['MSH.1'] = "|";

            Comment


            • #7
              Re:How to Initialize TMP?

              What alberto said sounds right. Something like tmp = new XML('<MSH></MSH>'); might also work. There is also a createSegment method available that does that for you.
              Jacob Brauer
              Director, Software Development
              NextGen Healthcare

              sigpic

              Comment


              • #8
                Re:How to Initialize TMP?

                Oh, okay. Thank you!

                Comment

                Working...
                X