Announcement

Collapse
No announcement yet.

Help in setting outbound message "tmp" from a text file.

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

  • Help in setting outbound message "tmp" from a text file.

    I have the following code in my transformer:

    var contents = FileUtil.read('Response.hl7') + "";
    tmp = SerializerFactory.getHL7Serializer(false, false, true).toXML(contents).toString();

    tmp['MSH']['MSH.7']['MSH.7.1'] = DateUtil.getCurrentDate("yyyyMMddhhmmss");

    The assignment for tmp['MSH']... fails?

    What am I doing wrong?

    The reason I am reading from a file is that I want this to be dynamic (i.e. the contents of the file can be changed to provide a different response).

  • #2
    You need to put a template message in the outbound message template.
    Stefan

    Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

    Comment


    • #3
      Originally posted by StefanScholte View Post
      You need to put a template message in the outbound message template.
      Stefan,

      Thanks for the quick response. I do have the template message and that works fine.

      However, in this case I want to be able to replace the template message with a completely new message that is read from a file.

      Comment


      • #4
        Well Here's what I have done recently with an query response channel.

        in the outbound template I put only the MSH segment (and only the pipes)
        Then when you turn to the tab and drag a field onto the javascript it looks like this:

        tmp['MSH']['MSH.7']['TS.1'] (nothing fancy)

        but when you want to use the PID segment or other then you need to use
        tmp['ADR_A19.QUERY_RESPONSE']['PID']['PID.3']['CX.4']['HD.1']
        in my case it is tmp['ADR_A19.QUERY_RESPONSE']
        I don't know what type of message you want to generate.

        I developed this message using an outbound template. and when finished I deleted the entire message except for the MSH segment.
        I hope this will point you in the right direction.

        kind regards.
        Stefan

        Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

        Comment


        • #5
          Originally posted by StefanScholte View Post
          Well Here's what I have done recently with an query response channel.

          in the outbound template I put only the MSH segment (and only the pipes)
          Then when you turn to the tab and drag a field onto the javascript it looks like this:

          tmp['MSH']['MSH.7']['TS.1'] (nothing fancy)

          but when you want to use the PID segment or other then you need to use
          tmp['ADR_A19.QUERY_RESPONSE']['PID']['PID.3']['CX.4']['HD.1']
          in my case it is tmp['ADR_A19.QUERY_RESPONSE']
          I don't know what type of message you want to generate.

          I developed this message using an outbound template. and when finished I deleted the entire message except for the MSH segment.
          I hope this will point you in the right direction.

          kind regards.
          Thanks much Stefan for the response. Since I wanted the tmp variable to be completely dynamic, I cannot use this as I cannot figure out how to perform a complete substitution of tmp from the HL7 in the read file.

          I changed my logic to require me to just update for the fields I need changing. i.e. using your approach of setting the relevant tmp fields. This worked and so I have what I need.

          Thanks again for taking the time to respond.

          Comment


          • #6
            you should be able to replace tmp but you need to do it with an XML object
            Code:
            // something like this:
            tmp = new XML(SerializerFactory.getHL7Serializer(false, false, true).toXML(contents));
            Daniel Svanstedt
            Software Engineer
            Mirth Corporation

            Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
            Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

            Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!

            Comment


            • #7
              Dan,

              Thanks much. This is exactly what I was looking for.

              Kind regards.

              Comment


              • #8
                Originally posted by dans View Post
                you should be able to replace tmp but you need to do it with an XML object
                Code:
                // something like this:
                tmp = new XML(SerializerFactory.getHL7Serializer(false, false, true).toXML(contents));


                What if the outbound message template is X12 and not XML?

                Comment


                • #9
                  If you look under the reference tab you will notice a conversion method
                  called: "Convert X12 to XML" and "Convert XML to X12"

                  Those should suit your needs.

                  Kind regards
                  Stefan Scholte
                  Stefan

                  Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

                  Comment

                  Working...
                  X