Announcement

Collapse

NextGen (Mirth) Connect 3.9.1 Released!

NextGen (Mirth) Connect 3.9.1 is now available as an appliance update and on our GitHub page. This release contains bug fixes and adds support for eHealth Exchange UDDI providers in the Interoperability plugin. 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

Outbound ER7 from an XML file

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

  • Outbound ER7 from an XML file

    I would like to be able to take a non-HL7 XML file and generate an ER7 output by mapping values from the input file into designated fields. After about a dozen hours of reading and messing around, I think I'm very close to having this figured out, but I'm stumped on one question: how do I format the input XML file to map values to variables that I can then use in my transformer? Would it be possible to show a minimal input XML file that specifies, say, a last name that should be mapped to variable pd_lname, which could then be plugged into the appropriate spot in the ER7 using the transformer?
    Much obliged for any help with this!
    Warm regards,
    Roy Feague
    Satori Labs

  • #2
    Re: Outbound ER7 from an XML file

    Roy,

    The main steps to do this are:

    1) Define an outbound channel
    2) Populate the transformer template with an example HL7 message of the ER7 type you would like to output. (This can be as simple as a MSH segment with the name of the message and version)

    If you are reading in XML, then Mirth allows you to reference the values directly in the transfomer.

    If your xml looked like this:

    Code:
    <data>
        <fname>Chris</fname>
        <lname>Lang</lname>
    </data>
    You can reference this data from the transformer (or filter) by using:
    Code:
    var fname = msg[&#039;fname&#039;];
    //or
    var fname = msg.fname;
    You do not need to specify the parent XML element ("data" in my example).

    You can use:
    Code:
    logger.debug(msg)
    to view the contents of the XML that Mirth is using.

    To build the actual ER7 you will need to populate fields in the template. This looks something like this:
    Code:
    tmp[&#039;PID&#039;][&#039;PID.5&#039;][&#039;XPN.1&#039;][&#039;FN.1&#039;] = msg[&#039;lname&#039;]
    This will set the PID.5/XPN.1/FN.1 (family name) segment in your template to the contents of the "lname" element in your incoming XML.

    Let me know if that helps!
    -Chris
    Chris Lang

    Comment


    • #3
      Re: Outbound ER7 from an XML file

      One thing to note, if you are using the Message Builder type in your Transformer, you would drag the segment from the HL7 tree to the Message Segment field (top) (tmp[&#039;PID&#039;][&#039;PID.5&#039;][&#039;XPN.1&#039;][&#039;FN.1&#039;] for example). Your mapping would be msg[&#039;lname&#039;]. Mirth will handle the appropriate code generation to accomplish this.

      One thing to be careful with is adding non-existent segments. If your template ER7 does not contain a segment you would like to map to, you can not use the Message Builder. In this case you must use the Javascript step and manually define the mapping:

      Code:
      tmp[&#039;PID&#039;][&#039;PID.5&#039;][&#039;XPN.1&#039;][&#039;FN.1&#039;] = msg[&#039;lname&#039;];
      (The reason you have to do this is because the MessageBuilder sets the "text" property on the node from the template. This is necessary to overwrite the original contents from the ER7. If the node does not exist, then accessing the "text" property will lead to null-pointer exceptions. When you perform the assignment directly in the Javascript, it sets the &#039;FN.1&#039; element to the contents of the msg[&#039;lname&#039;] element and will create any necessary parent elements automatically.)

      -Chris
      Chris Lang

      Comment


      • #4
        Re: Outbound ER7 from an XML file

        Posted on main list

        Comment

        Working...
        X