Eduard Lebedyuk · Jun 16, 2020 go to post

How many files are there in total?

How many (on average) do you need to process per day?

Eduard Lebedyuk · Jun 15, 2020 go to post

Still interested.

Thanks for the info.

Does dedicated license server not support application licenses?

Eduard Lebedyuk · Jun 12, 2020 go to post

Not really.

Object ByRef means pointer itself may be changed (so we need to pass a pointer to a pointer), which is exactly what happens in this method.

A more correct qualifier would be Output as old object is always discarded.

But initializing stfp before the call would serve no purpose in this case.

Eduard Lebedyuk · Jun 12, 2020 go to post

Remote path should be just:

set remotePath="/NEW.txt"

That said, this error

Ошибка '-2147014836': A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.   

looks like you don't have the network connectivity. Have you tried to connect with Putty from the same server as Ensemble?

Eduard Lebedyuk · Jun 11, 2020 go to post

Docs specify that Connect should come before Authentication.

Try this code:

Try {
    Set ssh = ##class(%Net.SSH.Session).%New()

    Set sc = ssh.Connect(host)
    Write:$$$ISERR(sc) "Connect:", $System.Status.GetErrorText(sc),!
    
    Set sc = ssh.AuthenticateWithUsername(username, password)
    Write:$$$ISERR(sc) "Auth: ", $System.Status.GetErrorText(sc), !
    
    #dim sftp As %Net.SSH.SFTP
    Set sc = ssh.OpenSFTP(.sftp)
    Write:$$$ISERR(sc) "SFTP: ", $System.Status.GetErrorText(sc), !
    
    Set sc = sftp.Dir("/", .contents, , $$$YES)
    Write:$$$ISERR(sc) "Dir: ", $System.Status.GetErrorText(sc), !
    
    Zwrite contents
    
    //If 'sftp.Disconnect() Write "Failed to logout",!

} Catch ex {
    Set sc = ex.AsStatus()
    Write "Exception: ", ex.DisplayString(), !
}
Eduard Lebedyuk · Jun 9, 2020 go to post
&sql(SELECT Name, DOB, Gender INTO :Name, :DOB, :Gender FROM osuwmc_RQGPatient.DataTable WHERE MRN=:MRN)
Eduard Lebedyuk · Jun 9, 2020 go to post
...
quit $classmethod(class, index _ "Exists", value)

As you presumably want to return the value.

Eduard Lebedyuk · Jun 9, 2020 go to post

%JSON.Adaptor does not construct an intermediate dynamic object. You can use %ObjectToAET to convert normal object into dynamic object:

set dynObj = ##class(%ZEN.Auxiliary.altJSONProvider).%ObjectToAET(obj)

There are two approaches:

1. Create a "result set" class to hold the results (interestingly, InterSystems provides %XML.DataSet and other tools for this specific use case with XML/SOAP. Docs):

Class Test.JSONRS Extends (%RegisteredObject, %JSON.Adaptor)
{
Property count As %Integer;
Property results As list Of Book;
}

2. Simple approach:

  • Output header {"results": 3, "items": [
  • Call %JSONExport on each book (don't forget the comma at the end)
  • Output footer ]}

Despite being hacky, the second approach is better:

  • If JSON export on each individual object is successful it works every time and if some object fails we won't get valid a JSON anyways
  • It can be easily generalized to use with any type of result
  • It does not hold a large structure in memory as each object is loaded/displayed individually.

That said, I generally recommend against supplying count in query results because of many reasons:

Eduard Lebedyuk · Jun 9, 2020 go to post

So %Dictionary.CacheClassname would be my table name then?

Well, class name. If you want you can convert table name to class name with:

set:table'["." table=$$$DefaultSchema_"."_table	// support unqualified names
set class = $$$GetClassNameFromIQN(table)

I don't have to use any :sql.... type code for it to do the lookup? 

You can but you don't have to.

What about the existing EXISTS function that already exists that is used for Data Lookup Tables (lut)?

It's a separate function that works only with Data Lookup Table  (which are actually not tables at all).

Eduard Lebedyuk · Jun 9, 2020 go to post

You'll need a Custom Function.

If the lookup field is indexed (Location in your case) you can use this function for all Lookup checks:

ClassMethod Exists(class As %Dictionary.CacheClassname, index As %String, value As %String) As %Boolean [ CodeMode = expression]
{
$classmethod(class, index _ "Exists", value)
}