First Steps: Building a Simple Interface

Modify the MSH Segment

Let’s tackle the third and fourth interface requirements:

3. We need to set the MSH ‘Sending Application’ field to “First Steps”.

4. We need to set the MSH ‘Sending Facility’ field to “Administration”.

Using annotations to revisit the Out variable’s node tree, we can see the values that these fields are currently populated with:

Screen Shot 2014-06-11 at 11.05.40

Let’s replace these with the requested values!

Step 1: Set the MSH “Sending Application” field to “First Steps”

  1. Start typing out the line of code below. Notice that auto-completion quickly refines the choices for you! Choose the first one (‘Sending Application‘):
  2. Notice that auto-completion will continue to drill down through the node tree, offering you options based on the selections that you make. To isolate the ‘Sending
    Application’ field data that we wish to change, select the ‘Namespace ID‘ field:
  3. Complete the line of code by assigning “First Steps” to the string:
    Screen Shot 2014-06-11 at 11.09.48

Step 2: Set the MSH ‘Sending Facility’ field to ‘Administration’

This procedure is just like the previous one!

  1. Start typing the line of code below and use auto-completion to drill down to ‘Sending Facility‘:
  2. From the options that auto-completion provides, select ‘Namespace ID‘ and assign the field the value “Administration”:
    Screen Shot 2014-06-11 at 11.14.05
  3. Move the trace() function call from the previous section to this new section of code, so that we can examine the results:
    Screen Shot 2014-06-11 at 11.22.54

Step 3: Examine the results

We moved the trace down to this section so that you can check to see if your changes worked. Simply click on the trace’s ADT annotation to view the data (old values on the right):

Screen Shot 2014-06-11 at 12.40.14

Sample Code

Here is a copy-and-paste version of the code we’ve just created:

function main(Data)
   -- (1) Parse the HL7 message
   local Msg, Name = hl7.parse{vmd = 'demo.vmd', data = Data}
   local Out = hl7.message{vmd = 'demo.vmd', name = Name}

   -- (2) Map the incoming message to the outgoing message

   -- (3) Alter the MSH segment data
   Out.MSH[3][1] = "First Steps"
   Out.MSH[4][1] = "Administration"

   -- (4) Modify the PID data

   -- (5) Push the outgoing message into the Iguana queue

We are nearly there! To meet the last of our interface requirements, we must modify the Sex field to use standard HL7 codes.

Leave A Comment?