Leveraging VMD files created with Chameleon/Python

If you are one of our many long-term, loyal customers, you might encounter the following scenario:

Your company has several hundred Chameleon VMD files in action, representing millions of dollars of development effort. These VMD files map HL7 data into a set of Chameleon “tables” using Chameleon’s table grammar, traditional mapping structure, and Python. Clearly, this is not a resource to be taken lightly; it’s an investment that you definitely want to leverage moving forward.

Understanding this, we made sure that when we released Iguana 5 and revamped our approach to data mapping, we still kept traditional Chameleon mapping functionality intact.

But, what about your own product cycle? Inevitably, you will need to develop a new version of your application that includes cool new features and cool new integration capabilities. You can take advantage of Iguana’s new tools (such as the Translator and Lua scripting) to develop these new data elements, but what if you also want to leverage all your existing mapping work that you did with Chameleon/Python? You should not have to completely reinvent the wheel.

We have a simple solution that makes incorporating older VMDs into new Translator projects easy. The process is simple:

  1. In your Iguana Translator script, use our chm.parse() function to invoke the existing Chameleon VMD file. This will allow you to parse HL7 information into your existing set of table structures.
  2. Create a new table node tree using our db.tables() function, and copy this mapped data into it. This is where things can become a little bit complicated; the new table tree is flat (simply a list of tables), whereas the incoming table structure produced by chm.parse() may be nested with “table groups” (thanks to Chameleon’s native table grammar). This requires a little bit of code to resolve (which we provide below).
  3. Now you can carry on with your project and address any new mapping requirements using the Iguana Translator and Lua scripting.

The beauty of this technique is how easily you can maintain interfaces moving forward. Because you are working in the Translator environment with Lua scripts, adding new data elements and upgrading interfaces for your customers will be very straightfoward.

How It Works

To see a working example of this solution, download and import this project zip file into your channel: example.zip

This code performs two important functions at once:

  • Leverages an existing VMD (implemented using traditional Chameleon mapping)
  • Adds new functionality with Lua scripting without needing to re-implement all that mapping code

This project also demonstrates some best practices by very cleanly separating concerns into three VMD files:

  • To get started, we need the original VMD file, acme1.vmd. This file was created with traditional Chameleon mapping grammar using Chameleon’s GUI and Python. We will leverage this code by invoking it with chm.parse().  This function gives us a ‘table grammar’ tree derived from Chameleon’s GUI.
  • To make use of this logic, we need to copy the Chameleon-derived tree into a ‘flat table’ tree produced by db.tables(). To do this, we use the table.vmd file as an argument for db.tables(). The ‘adapter’ module has the logic required to iterate from the tree produced by chm.parse().  The end result? Our data will reside in a set of tables just as if the code had been implemented within Lua rather than with the traditional Chameleon mapping.
  • Finally, we use the adt.vmd file to parse the HL7 message for additional mappings in Lua.  This VMD file gives us a complete, independent HL7 tree that we work with as we would any data in the Translator.

This approach makes it much easier to maintain the project. You can easily extend the functionality and add additional target data by simply extending the table.vmd file with more tables/columns.

Here is a quick screenshot of the code in action:

Notice how we even have access to the information coming from Python log statements? Cool!

As you can see, this solution allows you to augment traditional mappings (created using Chameleon/Python) with newer mappings (created using the Translator/Lua).

If you have any questions or comments, please feel free to let me know!

Eliot Muir

CEO, iNTERFACEWARE