Article Gevorg Arutiunian · Dec 13, 2018 2m read

Get a list of Ensemble Lookup Tables and Schema documents in the current namespace

(Originally posted by @Ben Spead on June 25, 2014)

This code snippet generates a list of Ensemble Lookup Tables and Schema documents in the user's current namespace. Run the code by running the class method "test":


Class benspead.EnsTablesSchema
{
classmethod test() {
If ##class(%Dictionary.CompiledClass).%ExistsId("Ens.Util.LookupTableDocument") {
// only supported in Ensemble 2012.1+
Write !,!,"Exporting Ensemble Lookup Tables..."
Set sc = $$$OK
Set rs = ##class(%ResultSet).%New("Ens.Util.LookupTableDocument:List")
Do rs.Execute()
While rs.Next() {
Set item=rs.Data("name")
Write "document found: "_ item,!
}
Do rs.Close()
Set rs=""
}
If ##class(%Dictionary.CompiledClass).%ExistsId("EnsLib.HL7.SchemaDocument") {
Write !,!,"Exporting Ensemble HL7 Schemas..."
Set sc = $$$OK
Set rs = ##class(%ResultSet).%New("EnsLib.HL7.SchemaDocument:List")
Do rs.Execute()
While rs.Next() {
Set item=rs.Data("name")
Continue:$listfind($lb("2.1.HL7","2.2.HL7","2.3.HL7","2.4.HL7","2.5.HL7","2.6.HL7","2.7.HL7","2.3.1.HL7","2.5.1.HL7","2.7.1.HL7","ITK.HL7")
,item)
Write "document found: "_ item,!
}
Do rs.Close()
Set rs=""
}
}
}

Here's a link to the code on GitHub: https://github.com/intersystems-community/code-snippets/blob/master/src/cls/benspead/EnsTablesSchema.cls

Comments

Evgeny Shvarov · Dec 16, 2018

Hi Gevorg!

Is this fair for InterSystems IRIS as well? 

0
Salma Sarwar · Aug 23, 2019

Hi

I would like to use this code to export the custom  schema files to a specific directory.  Is that possible, at the moment this only presents me with a list of names.

Thank you for your help.

Kind Regards,

Salma

0
Gevorg Arutiunian  Aug 23, 2019 to Salma Sarwar

Hi @Salma Sarwar

You can export custom schemes using this way: do ##class(Ens.Util.LookupTable).%Export("myFile.xml", "myTab")

0