Using Cache terminal to get SDA schema

97 views
Skip to first unread message

Prahalad

unread,
Mar 31, 2011, 4:58:25 AM3/31/11
to InterSystems: Ensemble in Healthcare
I am trying to output the xml schema of the SDA using the below
commands - is there an easy way to output the schema from terminal to
a file ?

do ##class(HS.SDA.Address).XMLSchema()
do ##class(HS.SDA.Administration).XMLSchema()
do ##class(HS.SDA.Alert).XMLSchema()
do ##class(HS.SDA.Allergies).XMLSchema()
do ##class(HS.SDA.ContactInfo).XMLSchema()
do ##class(HS.SDA.Container).XMLSchema()
do ##class(HS.SDA.Diagnosis).XMLSchema()
do ##class(HS.SDA.Document).XMLSchema()
do ##class(HS.SDA.DosageStep).XMLSchema()
do ##class(HS.SDA.Encounter).XMLSchema()
do ##class(HS.SDA.FamilyHistory).XMLSchema()
do ##class(HS.SDA.Guarantor).XMLSchema()
do ##class(HS.SDA.HealthFund).XMLSchema()
do ##class(HS.SDA.LabResult).XMLSchema()
do ##class(HS.SDA.LabResultItem).XMLSchema()
do ##class(HS.SDA.Medication).XMLSchema()
do ##class(HS.SDA.Name).XMLSchema()
do ##class(HS.SDA.NextOfKin).XMLSchema()
do ##class(HS.SDA.Observation).XMLSchema()
do ##class(HS.SDA.Order).XMLSchema()
do ##class(HS.SDA.PastHistory).XMLSchema()
do ##class(HS.SDA.Patient).XMLSchema()
do ##class(HS.SDA.PatientLanguage).XMLSchema()
do ##class(HS.SDA.PatientNumber).XMLSchema()
do ##class(HS.SDA.PhysicalExam).XMLSchema()
do ##class(HS.SDA.Plan).XMLSchema()
do ##class(HS.SDA.Problem).XMLSchema()
do ##class(HS.SDA.Procedure).XMLSchema()
do ##class(HS.SDA.QuickStream).XMLSchema()
do ##class(HS.SDA.QuickXML).XMLSchema()
do ##class(HS.SDA.Result).XMLSchema()
do ##class(HS.SDA.SocialHistory).XMLSchema()
do ##class(HS.SDA.SuperBaseClass).XMLSchema()
do ##class(HS.SDA.SuperClass).XMLSchema()
do ##class(HS.SDA.SuperGroupClass).XMLSchema()
do ##class(HS.SDA.SuperSerialClass).XMLSchema()

Dale du Preez

unread,
Mar 31, 2011, 9:19:10 AM3/31/11
to ensemble-in...@googlegroups.com
Hi Prahalad,

I am not sure why you need the HealthShare SDA schema, but I think it is
worth discussing the more general issue of writing out an XML schema
from Cache/Ensemble/HealthShare. The %XML.Schema class is designed to
work in conjunction with %XML.Writer to write out XML schema information.

Have you investigated using this approach?

Dale

Prahalad

unread,
Apr 3, 2011, 9:53:45 AM4/3/11
to InterSystems: Ensemble in Healthcare
Hi Dale,

I guess I was trying to avoid the issue :-) but I had set up a class:

Class Custom.HIXNYDEVPR.LCLDEV.BasicXMLWriter Extends
%RegisteredObject
{

/// write one object to a file
ClassMethod WriteOneToFile(cls) As %Status
{
set writer=##class(%XML.Writer).%New()
set writer.Indent=1

set file="C:/temp-HIXNY-NB/hixny/discussion/xmlstuff/
SDAXMLSchema/"_cls_".xml"
set status=writer.OutputToFile(file)
if $$$ISERR(status) do $System.Status.DisplayError(status) quit $$
$ERROR()

set status=writer.WriteComment("Object class is "_cls)
if $$$ISERR(status) do $System.Status.DisplayError(status) quit $$
$ERROR()

set status=writer.RootObject(cls)
if $$$ISERR(status) do $System.Status.DisplayError(status) quit $$
$ERROR()

quit status
}

}

and was trying to run the following command from terminal:

HSEDGE>do
##class(Custom.HIXNYDEVPR.LCLDEV.BasicXMLWriter).WriteOneToFile("HS.SDA.Address")

<INVALID OREF>zObject+24^%XML.Writer.1

The error seems to tell me that the ^%XML.Writer.1 object has not been
instantiated?? I have tried adding the class to my namespace
%XML.Writer package, do I have to put it in the same package
Custom.HIXNYDEVPR.LCLDEV. or something.

regards
Prahalad

P.S.
We are trying to get the SDA schema, with the hope of performing
custom transformations to data that is being stored in the ECR. Is
this functionality somehow already inbuilt into some methods ?

On Mar 31, 9:19 am, Dale du Preez <dale.dupr...@intersystems.com>
wrote:
> > do ##class(HS.SDA.SuperSerialClass).XMLSchema()- Hide quoted text -
>
> - Show quoted text -

Dale du Preez

unread,
Apr 4, 2011, 11:19:10 AM4/4/11
to ensemble-in...@googlegroups.com
Hi Prahalad,

You should be able to get the schema output using code similar to the
following:

Set schema = ##class(%XML.Schema).%New()
Set writer = ##class(%XML.Writer).%New()
Set writer.Indent = 1
Set status = writer.OutputToFile("Test_File.xsd")
If $$$ISERR(status) Quit status
Set status = writer.AddSchemaNamespace()
If $$$ISERR(status) Quit status
Set status = schema.AddSchemaType("HS.SDA.Container")
If $$$ISERR(status) Quit status
Set node = schema.GetSchema("") // empty namespace
If $IsObject(node) {
Set status = writer.DocumentNode(node)
If $$$ISERR(status) Quit status
}
Quit status

The approach you are using for your code below is for writing out the
contents of an object instance, not for writing out the schema for an
object.

I hope that helps,
Dale

Prahalad

unread,
Apr 5, 2011, 12:56:04 AM4/5/11
to InterSystems: Ensemble in Healthcare
Hi Dale,

I tried passing in the name of the class for in the empty namespace
but get an empty xsd.

Class Custom.HIXNYDEVPR.LCLDEV.BasicXMLWriter Extends
%RegisteredObject
{

/// write one object to a file
ClassMethod WriteOneToFile(cls) As %Status
{
Set schema = ##class(%XML.Schema).%New()
set writer = ##class(%XML.Writer).%New()
set writer.Indent=1

set file = "c:/"_cls_".xsd"
set status = writer.OutputToFile(file)
if $$$ISERR(status) do $System.Status.DisplayError(status) quit $$
$ERROR()

set status = writer.WriteComment("Object class is "_cls)
if $$$ISERR(status) do $System.Status.DisplayError(status) quit $$
$ERROR()

//set status = writer.RootObject(cls)
//if $$$ISERR(status) do $System.Status.DisplayError(status) quit $
$$ERROR()
If $$$ISERR(status) Quit status
Set status = writer.AddSchemaNamespace()
If $$$ISERR(status) Quit status
Set status = schema.AddSchemaType("HS.SDA.Container")
If $$$ISERR(status) Quit status
Set node = schema.GetSchema(cls) //adding cls empty namespace
If $IsObject(node) {
Set status = writer.DocumentNode(node)
If $$$ISERR(status) Quit status
}
}
}

>set bxw = ##class(Custom.HIXNYDEVPR.LCLDEV.BasicXMLWriter).%New()
>do bxw.WriteOneToFile("HS.SDA.Address")

HS.SDA.Address.xsd contents:
<?xml version="1.0" encoding="UTF-8"?>
<!--Object class is HS.SDA.Address-->

>w status:
<UNDEFINED>^Custom.HIXNYDEVPR.LCLDEV.BasicXMLWriter.1 *status

On Apr 4, 11:19 am, Dale du Preez <dale.dupr...@intersystems.com>
wrote:
> Hi Prahalad,
>
> > ##class(Custom.HIXNYDEVPR.LCLDEV.BasicXMLWriter).WriteOneToFile("HS.SDA.Add­ress")
> >> - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages