Mapping between different code sets

Is there an out-of-the-box or accepted standard method for loading up mappings between different code sets and then referencing these mappings (both directions) from DTL? First thought was the built in Lookup() and corresponding data tables but these only work in one direction (key -> value) and not the reverse. Obviously I can build my own classes to support a two way mapping but am wondering if there's a standard way of achieving this. The mapping should contain the code and display name from each of the code sets and allow mapping based on either code or display name.

Thanks

  • 0
  • 0
  • 290
  • 1
  • 1

Answers

Hi Duncan,

The standard lookup tables are the closest thing to what you're looking for but as you noted, they don't support reverse lookups.  I think you will need something custom for this.  The easiest solution is probably to implement a reverse lookup for existing lookup tables.  If you implement a new classmethod to do this in a class that extends Ens.Rule.FunctionSet, then that classmethod will be available to DTLs.

-Brendan

 

Just to add on to this, lookup tables are stored in ^Ens.LookupTable, subscripted by the table name and then the key.  The value of each node is the lookup value of the key in the subscript.

For example, if you have a table named Codes which contains a key named 123 that maps to value "ABC", it will look like this in the global:

^Ens.LookupTable("Codes",123)="ABC"

The reason reverse lookups are not supported is because we allow many keys to map to the same value.  So if you need to find a key, given a value, there may be many values that match.

Writing code to perform a reverse lookup will involve copying the ^Ens.LookupTable global into a variable subscripted by value rather than by key, like this:

ReverseLookupTable("Codes","ABC")=123

and then performing a lookup on that variable.