Announcement

Collapse
No announcement yet.

Mirth Channel to move xml

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

  • Mirth Channel to move xml

    Hi Guys

    OK so I have a mirth channel that I want to monitor a folder, pick up XML, read a field, create a folder named after the content of that field, and then move the XML to it. I have a source transformer to read the data into a variable called DeviceID which I then use for the folder to write to.

    It's all working except the file I end up with is a junk 151Kb file

    Channel
    https://www.dropbox.com/s/6vwctav5tq...E_XML.xml?dl=0

    Sample XML file
    https://www.dropbox.com/s/sriqzg61z1...25041.xml?dl=0

    Probably something simple?

    Thanks!

    Matthew

  • #2
    Your destination File Type is set to binary. XML is text. Update that. You may also want to update your Template to be: ${XmlUtil.prettyPrint(${message.rawData})} so the XML is formatted properly on the other side.

    -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
    -= [email protected]
    -= Mirth Connect (Advanced)-certified
    -= Gold member of HL7.org
    -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

    Comment


    • #3
      I didn't actually load your channel, but looking at the xml, don't use an outbound template in your transformer if you want the message to pass through. When you use an outbound template that is the starting point for your outbound message and you have to apply any changes to the variable tmp instead of msg.

      You also will probably want to turn off "strip namespaces" from your xml datatype options if you intend to keep the namespaces present in the inbound message. That will probably change how you access your DEVICEID.

      In your destination templates, it's generally good practice to use ${message.encodedData} instead of ${message.rawData}. rawData is your message at the start of the destination transformer, and encodedData is your message after transformations. If your transformer doesn't alter the message, both values will be the same.

      Edit: Jack posted while I was composing, but that is also good advice.

      Comment


      • #4
        I didn't even catch the Outgoing Template... thanks agermano. That could be why the formatting was ugly, but I stand behind the binary/text setting. "raw" will get your the original file output (provided there is no outbound template) but yes, use encoded if you are going to format/change it at all.

        -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
        -= [email protected]
        -= Mirth Connect (Advanced)-certified
        -= Gold member of HL7.org
        -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

        Comment


        • #5
          I always use encoded by default, unless I know that I don't want it for a specific reason. You'll run into less issues that way.

          Comment


          • #6
            Thanks guys will try those suggestions now
            The outgoing template is irrelevant and left over from the old channel I started from
            I'll get rid of it!

            Comment


            • #7
              Outbound templates are for very specific purposes and will cause lots of issues. Use them wisely!

              -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
              -= [email protected]
              -= Mirth Connect (Advanced)-certified
              -= Gold member of HL7.org
              -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

              Comment


              • #8
                I got rid of the template, the Strip Namespaces checkbox and switched to text and the amended code for the Destination box and...all now working thanks a lot much appreciated!

                Comment

                Working...
                X