Written by

Enterprise Application Development Consultant at The Ohio State University Wexner Medical Center
MOD
Question Scott Roth · Jan 9, 2017

Automatting Data Lookup Table Import

Is there a way to have a Data Lookup table be automatically updated via a script or cache code? We have a file that is being created by our EMR, and we need to import it into Ensemble to update it. Just trying to see if we can automate this process.

Thanks

Scott Roth

Ohio State University Wexner Medical Center

Comments

Brendan Batchelder · Jan 10, 2017

class Ens.Util.LookupTable has %Import and %Export methods.  You can use %Export to export an existing table to see the format expected by %Import.

Another option is to import a csv file using the SQL Data Import Wizard.  You can find that at System Explorer -> SQL and then click the 'Wizards' link at the top and choose Data Import.  I believe the csv file needs 3 columns: tablename, key, value.  The table name gets repeated for every row.  I'm not sure if this can be automated.

The last option is to edit the globals directly.  Ens.Util.LookupTable doesn't use standard default storage.  Instead, everything is stored in ^Ens.LookupTable with this format:

^Ens.LookupTable("TableName","key")="value"

The last two options break the abstraction barrier so if the way lookup tables are stored ever changes, they'll stop working.  %Import and %Export are preferred.

0
Markus Mechnich · Jan 11, 2017

Export via $system.OBJ.Export(<LookupTableName>,<FilePath and FileName>).

The extension is ".lut". A LookupTable "TestLookupTable" can be exported as follows:

write $system.OBJ.Export("TestLookupTable.lut","c:\temp\lut1.xml")
0
Markus Mechnich  Jan 11, 2017 to Markus Mechnich

Import the exported LookupTable with $system.OBJ.Import() or any means available like Studio or System Management Portal.

0
Markus Mechnich · Jan 11, 2017

Packaging a LookupTable within a project:

Include the "*.lut" in a Studio Project. Then the LookupTable can be exported with other relevant development objects.

0
Markus Mechnich  Jan 11, 2017 to Markus Mechnich

This is how the LookupTable is projected to a Studio Document:

<?xml version="1.0"?><lookupTable><entry table="TestLookupTable" key="T1">V1</entry><entry table="TestLookupTable" key="T2">V2</entry></lookupTable>
0