No announcement yet.

Converting HL7 to XML

  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting HL7 to XML


    I am new to Mirth tool, can anyone help me in creating a channel which will convert HL7 file to XML file.

    Thanks in Advance

  • #2
    Re:Converting HL7 to XML


    I am also trying for the same thing, Can you help me in this if you got a solution.

    Thanks In Advance,


    • #3
      Re:Converting HL7 to XML

      Define a channel that reads hl7 plain files from a folder, and define a destination with type FileWriter ...

      Drag and drop the encoded message in the content of the file that the destination writes. I can't remember the exact name, but there is a variable that represents the original message as XML

      Hope that helps.


      • #4
        I've added this to the wiki at:

        I tried what was suggested above. Here are the steps I took and my results:
        Create a new channel and name it HL7toXML
        Incoming data is HL7 v2.x

        Source is set to File Reader with a valid directory.

        Destination is set to File Writer with a valid directory.
        File name is ${ORIGINALNAME}
        Append to file is No
        drag and drop the Encoded Data from Destination Mappings to Template
        Template is: ${message.encodedData}

        Saved and enabled the channel. Deployed the channel.

        It runs, and I get files in my destination directory that look exactly the same as the original files, which I expected because I didn't make any changes to the default transformer applied to Destination 1.

        What else does it take to do this? I read that Mirth's internal representation of the message is XML. Is encodedData Mirth's XML format? Obviously not.
        I've attached my exported channel.

        When I look at the channel xml, I see that the Destination 1 section looks like:
        <name>Destination 1</name>
        <property name="scheme">file</property>
        <property name="binary">0</property>
        <property name="username">anonymous</property>
        <property name="outputPattern">${ORIGINALNAME}</property>
        <property name="validateConnections">1</property>
        <property name="DataType">File Writer</property>
        <property name="FTPAnonymous">1</property>
        <property name="charsetEncoding">DEFAULT_ENCODING</property>
        <property name="password">anonymous</property>
        <property name="passive">1</property>
        <property name="template">${message.encodedData}</property>
        <property name="outputAppend">0</property>
        <property name="host">C:/mirth/xmlout</property>

        <transportName>File Writer</transportName>

        If I then go into the default transformer applied to Destination 1 -> Message Template tab and change the Outbound Message Template to HL7 v3.0, the transformer section in the exported channel xml file (see attachment) changes to:

        When I apply my changes to the channel and redeploy, I get HL7 v3.0 xml in my xmlout directory.

        So now I've got my first Mirth transformation simply using the built in tool, but XML isn't really what I need. My incoming HL7 files could have multiple messages in them.

        I need to:
        read each individual message in the file
        figure out the hl7 message type
        transform it to comma delimited text
        and sort them into individual directories based on message type
        Attached Files
        Last edited by jkimmel; 06-05-2009, 10:55 AM.