what's the format of the file to import lookup table ?
in the InterSystems management portal, I am in the lookup table viewer (interoperability>lookup Tables, I would like to use import function to convert our existing table from other system to intersystems lookup table.
so I converted our existing one like below and saved it as xxx.xml file locally. when I try to import, it says it is not a valid export file.
my question is " what's the valid format for a file to be valid to use to import for lookup table?"
we are using cloud and I do not have access to the server file , I tried to export one to see what format the file would be but I do not have access to the exported file to view the content.
<?xml version="1.0" encoding="UTF-8"?>
<Export
ts="2014-10-21 11:52:51">
<Document name="NH_Epic_ORU_NCDPH_OBX8.LUT">
<lookupTable>
<entry table="NH_Epic_ORU_NCDPH_OBX8" key="-">NEG</entry>
<entry table="NH_Epic_ORU_NCDPH_OBX8" key="+">POS</entry>
</lookupTable>
</Document>
</Export>
Comments
There are two formats for LUT:
Old one:
<?xml version="1.0" encoding="UTF-8"?><Exportgenerator="IRIS"version="26"zv="IRIS for UNIX (Red Hat Enterprise Linux 7 for x86-64) 2022.1 (Build 209U)"ts="2024-03-03 06:05:36"><Documentname="LUT_NAME.LUT"><lookupTable><entrytable="LUT_NAME"key="KEY">VALUE</entry><entrytable="LUT_NAME"key="KEY2">VALUE2</entry></lookupTable></Document></Export>New one:
<?xml version="1.0"?>
<lookupTable>
<entry table="LUT_NAME" key="KEY">VALUE</entry>
<entry table="LUT_NAME" key="KEY2">NALUE2</entry>
</lookupTable>
Looks like you're importing old format using new importer. Here's the code to import both versions:
ClassMethod ImportLUT(dir)
{
#include %occErrorswrite"Lookup Tables import from: " _ dir
set rs = ##class(%File).FileSetFunc(dir, "*.xml;*.XML;*.lut;*.LUT")
while rs.%Next() {
set tablePath = rs.Get("Name")
write"Importing: " _ tablePath,!
// table is the full path, the last part (denoted by *) is the actual file nameset tablePathNoExtension = $PIECE(tablePath, "/", *)
// asking for $PIECE with just delimiter asks for the first part, thus ignore anything after the .set tablePathNoExtension = $PIECE(tablePathNoExtension, ".")
write"Importing Lookup Table in " _ tablePathNoExtension,!
// lookup table should be named the file name (without extension)//do ##class(Ens.Util.LookupTable).%ClearTable(tablePathNoExtension)// Try the new import first.set sc = ..ImportLUTFile(tablePath)
// If we got an error, try legacy importif$$$ISERR(sc) {
write"New import failed. Trying legacy import",!
set sc=##class(Ens.Util.LookupTable).%Import(tablePath)
if$$$ISOK(sc) {
write"Import successful",!
}
}
// Error remains unfixed. Fail.if$$$ISERR(sc) {
write"Lookup Table import failure: ", $System.Status.GetErrorText(sc),!
do$system.Process.Terminate(, 1)
}
}
}
/// Adapted from EnsPortal.LookupSettings:Import/// Import lookup tables from file <var>Filename</var>ClassMethod ImportLUTFile(Filename As%String) As%String
{
Set tRS = ##class(%ResultSet).%New("%RoutineMgr:ImportItemList")
Set tSC = tRS.Execute(Filename)
Quit:$$$ISERR(tSC) tSC
Set tSC = $$$OKKill Select
For {
Quit:'tRS.Next(.tSC)
Set Name = tRS.Get("Name")
If$E(Name,*-3,*)=".LUT" {
Lock +^Ens.LookupTable(Name):2If '$TSet tSC = $$$ERROR($$$LockFailedToAcquireRead,$Name(^Ens.LookupTable(Name))) QuitSet Select($E(Name,1,*-4)) = ""
}
}
Quit:$$$ISERR(tSC) tSC
Quit:'$D(Select) $$$ERROR($$$GeneralError,"This file does not contain any lookup tables")
Set tSC = $system.OBJ.Load(Filename,"-d", .Err, .Loaded, 0)
Set Name = ""For {
Set Name = $O(Select(Name))
Quit:Name=""Lock -^Ens.LookupTable(Name)
}
Quit tSC
}I think in the sample you have inverted Old and New
I should have read this comment the first time my import failed! Updated my import file to the correct new version (the one with the `Export` and `Document` elements) and it worked like a charm. And just for reference, you don't have to put in your `zv` string or a `ts` at least with the version I am using, haha.
What's the version of the "source" system?
Try using the button "Import Legacy" instead of "Import".
Thank you, I used old version with import button and it worked.
We just started the project and our old system is cloverleaf. and we do not have access to VS neither so far, so I am glad it works through the GUI.