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]
- Create a Channel with the the following settings:
- Source = LLP Listener
- Destination = To Translator
- Channel name = Relative VMD Path
- Click the Add Channel button to create the channel.
Ignore the red warning messages, see resolving the milestone configuration error. - Open the Translator by clicking the Edit Script link at the bottom of the Destination tab.
- Download and import the Relative_VMD_Path_To_Translator.zip project file.
This file contains a skeleton project and six sample HL7 messages. - Iguana will load the project and data into the Translator, your screen should look like this:
Tutorial Instructions [top]
- 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
- Iguana automatically passes the message data to the
- Parse the message into a convenient read-only “node tree” structure.
Add the following lines of code to your script:
- The second line of code generates an error why is this?
- 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”… - So why did the first line work, lets look in the example directory:
And sure enough there is demo.vmd…
- The error mentions the “other” directory so let’s take a look:
- 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:
- Add the file using Project Manager in the Iguana Editor.
- Copy the file into the other directory.
- 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.- 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). - Click the [Add…] link next to other, and browse to find demo.vmd:
- Click Open to add the file, and the error should be gone:
- Checking the other directory shows the file has been added as expected:
- 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”.
- It possible to include other file types in a project, as in the Channel Manager app.
- Here are some of the included files:
- And they are all stored in the other directory using the same relative path rules:
- If you want to try this out yourself take a look at the Channel Manager in the Iguana Apps section.
- Here are some of the included files:
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]
- See Relative Paths for VMD Files in our Deployment Guide
- The Iguana production server install explains how to use a separate configuration directory (with relative VMD paths)
- See our other interface tutorials in this section
- See our general tutorials section
- See our code samples section