This topic contains 2 replies, has 2 voices, and was last updated by  Robert James 7 years, 7 months ago.

Convert HL7 to XML

  • I am looking for something that seems simple in concept, but appears difficult in practice using Iguana — unless I’ve missed something completely, and it would be nice if that were the case. I have a need to take a message received in HL7 notation and convert it to XML. Just straight up, convert it so that

    MSH|^~\&|K50|K50|SKYLIGHT|DEV|||ADT^A01|DevRad0000011|P|2.3|||AL|NE|

    becomes

    <MSH>
    <FIELD.1>|</FIELD.1>
    <FIELD.2>^~\&</FIELD.2>
    <FIELD.3>K50</FIELD.3>
    <FIELD.4>K50</FIELD.4>
    <FIELD.5>SKYLIGHT</FIELD.5>
    <FIELD.6>DEV</FIELD.6>
    <FIELD.9>
    <FIELD.1>ADT</FIELD.1>
    <FIELD.2>A01</FIELD.2>
    </FIELD.9>
    <FIELD.10>DevRad0000011</FIELD.10>
    <FIELD.11>P</FIELD.11>
    <FIELD.12>2.3</FIELD.12>
    <FIELD.15>AL</FIELD.15>
    <FIELD.16>NE</FIELD.16>
    </MSH>

    Is there a simpler way to do this than brute-forcing it by using :append to construct it as one long string?

    -Robert James,
    Interface Analyst,
    GetWellNetwork, Inc.

    OK, making process. The solution is dependent on the VMD for structure of the final XML file. What I’m seeing so far is that I can create a VMD that has a table (I’m using the MSH segment as a test) called MSH, and the column names are like “Field.1”, “Field.2”, and so forth. This is producing the following output:

    <Chameleon_Import>
    <SkylightADT>
    <MSH>
    <Field.1>|</Field.1>
    <Field.2>^~\&</Field.2>
    <Field.3>AMR03</Field.3>
    <Field.4>NCA</Field.4>
    <Field.6>NCA</Field.6>
    <Field.7>2015-09-17T17:07:29</Field.7>
    <Field.8>U987090</Field.8>
    </MSH>
    </SkylightADT>
    </Chameleon_Import>

    All of this is happening in the VMD, though, and it’s not something I want to have to work out — I’d prefer to stick with Lua code in the translator. But if I do that, I have to manually build the segments using appends, is that correct?

    -Robert James,
    Interface Analyst,
    GetWellNetwork, Inc.

Tagged: 

You must be logged in to reply to this topic.