Hi Tom,
You can have a look at this documentation : https://cedocs.intersystems.com/latest/csp/docbook/Doc.View.cls?KEY=EDIC... to help you to create a dicom production to send document to pacs.

If you are not on Ensemble, you have in the community installer for ENSDEMO production : https://openexchange.intersystems.com/package/irishealth-ensdemo

But in short, you have to create an EnsLib.DICOM.Document
Fill it with information about the patient, ect.
e.g

  Set pDocOut = ##class(EnsLib.DICOM.Document).%New()
  // Set patient data
  $$$THROWONERROR(tSC, pDocOut.SetValueAt("Toto^Toto", "DataSet.PatientName"))
  $$$THROWONERROR(tSC, pDocOut.SetValueAt(1, "DataSet.PatientID"))

  //Set pdf in EncapsulatedDocument
  $$$THROWONERROR(tSC, pDocOut.SetValueAt("application/pdf","DataSet.MIMETypeOfEncapsulatedDocument"))
  /// File is you binary pdf document
  IF '$IsObject(file) $$$THROWONERROR(tSC, $$$ERROR($$$FailedToNewClass, "%Stream.TmpBinary"))

  // DICOM Standard PS3.5: The Value Field containing Pixel Data, like all other Value Fields in DICOM, shall be an even number of bytes in length
  // Thanks Michel Liberado for this hack
  IF (($L(binary) # 2) '= 0) {
          // Any char would be fine but I want to have the End Of Transmission ASCII character
          $$$THROWONERROR(tSC, file.Write($CHAR(4)))
  }

  $$$THROWONERROR(tSC, pDocOut.SetValueAt(file,"DataSet.EncapsulatedDocument"))

Once you have your pDocOut you can send it to business process Demo.DICOM.Process.Storage

Hi Lucas,

All security settings are store in the %SYS databases.

You can access then with this query :

select * from Security.System

Or with this procedure

select * from Security.System_List()

If you want to do this in COS :

s ResultSet=##class(%ResultSet).%New("Security.System:List")
d ResultSet.Execute()
While ResultSet.Next() {
	zw ResultSet.Data("Name")
}

Like that you don't have to use the export function who only create files.

Now you can parse data and build your report directly from an homemade object.

Hi Blaise,

You can pass %OnNew expection to %New with this code snippet :

Class Test.PersitenceTest Extends %Persistent
{
 
Property mandatory As %String [ Required ];
 
Method %OnNew(mandatory As %String = "") As %Status
{
 
set ..mandatory = mandatory
 
$$$ThrowOnError(..%ValidateObject())
 
Quit $$$OK
}
 
}

 Now when you call the new method :

USER>set test = ##class(Test.PersitenceTest).%New()

  If $isobject($get(newerror))=1 Throw newerror
                                 ^
<THROW>%Construct+9^Test.PersitenceTest.1 *%Exception.StatusException ERROR #5659: Property 'Test.PersitenceTest::mandatory(10@Test.PersitenceTest,ID=)' required

Now you can catch you %OnNew expection anywhere :

ClassMethod test() As %Status
{
try {
set test = ##class(Test.PersitenceTest).%New()
}
catch ex {
Return ex.AsStatus()
}
Return $$$OK
}

Studio :

  • Like :
    • It's fast
    • Find in files directly on the server side
    • Intuitive
    • Debugging is not perfect but manageable
  • Dislike :
    • Only on windows
    • No easy to use with other third party file or software

Atelier :

  • Like :
    • Easy to use with source control
  • Dislike :
    • File synchronization with server especially BPL, DT, RecorMap
    • Complicate to configure
    • Slow

VS Code with Dmitriy's plugin

  • Like :
    • Modern UI
    • Crossplatform
    • Lite
    • Intuitive with no file synchronization concern
    • Fast
  • Dislike :
    • Can't edit, manage CSP files
    • No find in file on server side
    • Debugging not easy to use

Serenji :

I haven't tried it yet because you need to install some classes on the server side, but sound very promising for debugging.

Conclusion :

My main IDE is VSCode with Dmitriys's plugin and some times Studio for find in files, csp managment and debugging.

Do you expect to be writing code in a web-based editor five years from now?

Yes, why not, already a lot of people do it on Jupyter Notebook. 

Thanks Marc,

Your code work great.

We gain a factor ten with this implementation.

Below our current implementation.

/// Structure of pParms is Caché Multidimensional Array
/// Where :
/// pParms indicate the number of row in batch
/// pParms(integer) indicate the number of parameters in the row
/// pParms(integer,integerParam) indicate the value of the parameter whose position is integerParam.
Method ExecuteUpdateBatchParmArray(Output pNumRowsAffected As %Integer, pUpdateStatement As %String, pParms...) As %Status
{

set tStatus = $$$OK

try{

set pSQLStatement=pUpdateStatement

// JDBCGwy is an instance of the JDBC Gateway object. EnsLib.SQL.OutboundAdapter instantiates this automatically and stores a reference to it in ..%Connection.%JGProxy

// Prepare the SQL statement
Set pHS=..%JGProxy.prepareStatement(..%ConnHandle,pSQLStatement)

// executeParametersBatch expects tArgs to be a $LIST, with the following format:
// ParamCount, ParamSets, Type1, Param1, Type2, Param2, Type3, Param3, Type11,Param11… TypeNN,ParamNN
// 
// ParamCount is the number of parameters the query expects (in this example 2) 
// ParamSets is the number of rows we will be inserting in this batch
// Type1, Type2, ..., TypeN is an integer indicating the JDBC data type for the corresponding Param value (e.g. Param1, Param2, ..., ParamN)
// Param1, Param2, ..., ParamN is the value for the query parameter

set nbParam = pParms(1,1)
set nbBatch = pParms(1)

set $LIST(tArgs,1)=nbParam // How many parameters ("?") in it
set $LIST(tArgs,2)=nbBatch // We will insert nbBatch rows in this batch

set = 2

for k=1:1:nbBatch {



for l=1:1:pParms(1,k){

set = +1
set $LIST(tArgs,i)=12 // The JDBC data type for varchar is 12
set = +1
set $LIST(tArgs,i)=pParms(1,k,l) // Value for column Field1VarChar

}

}


// Perform the batch insert
// tResultCodes is a $LIST of integers indicating success/failure for each row in the batch
set tResultCodes = ..%JGProxy.executeParametersBatch(pHS,tArgs)

//Todo, Read list set pNumRowsAffected = $LISTLENGTH(tResultCodes)
set pNumRowsAffected = nbBatch 


// Remove Statement to avoid CURSOR Leaks
set sc = ..%JGProxy.removeStatement(pHS)

tArgs

}

catch exp{

Set tStatus = exp.AsStatus()
}

Quit tStatus
}

My guess is that you are concatenating string with the operator "&" (AND) instead of "_".

If you do so, ObjectScript will cast your string as boolean false, the result of (false and false and false) equals 0, the result you see in your question.

Method PatientInfo(ID As %String) As %Status#dim status as %Status=$$$OK
  SET myquery="SELECT GUID, IDType,IDValue FROM MergeHyland.TypeTwoDimesionCollection WHERE GUID ="_ID
  SET rset=##class(%ResultSet.SQL).%Prepare(myquery,.err,"")
    WHILE rset.%Next() {
    WRITE !,rset.GUID _ ":" _ rset.IDType_ ":" _ rset.IDValue
    }
  WRITE "End of data"
    return status
}

Hi Benjamin,

In some cases we have to use Ensemble as an ETL not an ESB.

So we extract lot of data, transform and load them throw the JDBC SQL Adapter in EnsLib. To do so, we dont do it line by line throw messages but ResultSet by ResultSet (one ResultSet can have more than 500 000 lines and 30 colones). This pattern work well.

But we have start to have time treatment issue. Our process took more than 8 hours. When we analyze it, what it cost time is the select and insert treatment.

We solved the problem of select treatment with this post : https://community.intersystems.com/post/jdbc-large-query-optimisation

So now, we are looking for a way to improve insert time. Our guess is to implement throw JDBC SQL Adapter in EnsLib the java pattern with PrepareStatement.addBatch() then executeBatch().

Do you have any idea to improve the insert treatment ?

Hi Marc,

I'm intereded by your sample code for this kind of optimisation even if we have to use a different EnsLib.SQL.GatewayResultSet.
Furthermore, we are currently looking for the same kind of optimisation in the other way, insert in JDBC batch mode. (https://www.tutorialspoint.com/jdbc/jdbc-batch-processing.htm)
I get in touch with our Sales Engineer and we will continu to discuss this by email.

When we will have improvement, i'll update this theard.