Relative paths for project files, for VMD files etc

In this article we will use VMD files with hl7.parse{} to demonstrate how relative paths for project files work. We placed the mapping code in a To Translator component, but it can be used in any component script.

Relative VMD files paths work in exactly the same way with all the following functions:

  • hl7.parse{} and hl7.message{}
  • chm.parse{}, chm.toXml{} and chm.transform{}
  • x12.parse{} and x12.message{}

We recommend that you type in the code for each step, but we also include complete Sample Code if you prefer to paste it in and follow along.

Note: In this example we installed Iguana in the C:\Iguana-5-6-20\ directory, which keeps the install/config path more concise (than C:\Program Files\iNTERFACEWARE\Iguana\…), and also complies with our recommendations for a production server.

You will need to substitute your own install path (by default C:\Program Files\iNTERFACEWARE\Iguana\) where C:\Iguana-5-6-20\ is used.

Tip: Relative paths used in the LLP Listener source component work in a similar (but different) way, see Relative Paths for VMD Files for more information.

Create the Channel [top]

  1. Create a Channel with the the following settings:
    • Source = LLP Listener
    • Destination = To Translator
    • Channel name = Relative VMD Path
  2. Click the Add Channel button to create the channel.
    Ignore the red warning messages, see resolving the milestone configuration error.
  3. Open the Translator by clicking the Edit Script link at the bottom of the Destination tab.
  4. Download and import the Relative_VMD_Path_To_Translator.zip project file.
    This file contains a skeleton project and six sample HL7 messages.
  5. Iguana will load the project and data into the Translator, your screen should look like this:

Tutorial Instructions [top]

  1. Pass the message data to the script.
    • Iguana automatically passes the message data to the main() function
    • The message can be accessed using the Data parameter
    • No action is needed
  2. Parse the message into a convenient read-onlynode tree” structure.
    Add the following lines of code to your script:
  3. The second line of code generates an error why is this?

    1. The error mentions the “other” directory so let’s take a look:
      Note: The other directory is <config dir>\edit\<user>\other\ in this case C:\Iguana-5-6-20\edit\admin\other.

      And sure enough the demo.vmd file is “missing”…
    2. So why did the first line work, lets look in the example directory:

      And sure enough there is demo.vmd…
  4. So how do we fix this? Basically we just need to add demo.vmd to the “other” directory, there are two ways to do this:
    1. Add the file using Project Manager in the Iguana Editor.
    2. Copy the file into the other directory.
  5. Let’s add the file using Project Manager.
    Note: You can also simply copy the file using File Explorer, feel free to try this out yourself.

    1. As it turns out we want to use the older (and simpler) demo.vmd from the Iguana install directory, rather than the upgraded (more complex) “example\demo.vmd”.
      Note: It might be a good idea to change the file name (but we are not going to bother).
    2. Click the [Add…] link next to other, and browse to find demo.vmd:
    3. Click Open to add the file, and the error should be gone:
    4. Checking the other directory shows the file has been added as expected:
  6. It possible to include other file types in a project, as in the Channel Manager app.
    1. Here are some of the included files:
    2. And they are all stored in the other directory using the same relative path rules:
    3. If you want to try this out yourself take a look at the Channel Manager in the Iguana Apps section.

Complete Sample Code [top]

Here is the completed code that you can cut and paste into your script:

function main(Data)
   local Msg, Name = hl7.parse{vmd = 'example/demo.vmd', data = Data}
   local Msg, Name = hl7.parse{vmd = 'demo.vmd', data = Data}
end

More Information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.