EnsLib.DICOM.Document - GetValueAt truncating "large" files


I have a process that receives a EnsLib.DICOM.Document, and then attempts to extract a PDF from the dataset to save to a folder.

When I use the GetValueAt method to get the pdf from the document (from the EncapsulatedDocument section), the status returned is 1, but I'm only getting the first 32648 characters(?) from the PDF.

I thought it was a string max length problem, but long strings are enabled and the final PDF is tiny (94kb) so it's not hitting the long string.

Is there some form of limit to using the GetValueAt method that I'm missing?


After working with WRC, I now have an answer.

If the DataSet property points to the MutabaleDateSet property then GetValueAt will return a stream if more than 32k.

If (as in my situation) the DataSet property points to the FixedDateSet property then GetValueAt will return a string of 32648.

The workaround provided by WRC did the trick for me:

               Try {
                   Set setStatus = $$$OK, getStatus = $$$OK
                   If 'pInput.Modified{
                       Set setStatus = pInput.SetValueAt(pInput.GetValueAt("DataSet.DocumentTitle",,.getStatus),"DataSet.DocumentTitle")}}
                       Catch e {
                           Set setStatus = e.AsStatus()}
                   If setStatus && getStatus{
                       Set X = pInput.GetValueAt("DataSet.EncapsulatedDocument",,.tSC)}


However there was an alternative of using the CreateFromDataSetFileStream method of the class EnsLib.DICOM.Document:

set tSC = ##class(EnsLib.DICOM.Document).CreateFromDataSetFileStream(pInput.DataSet.FileStream,pInput.DataSet.TransferSyntax,.dicomDocFromStream)

If tSC Set X = dicomDocFromStream.GetValueAt("DataSet.EncapsulatedDocument",,.tSC)

In both of these options, the next step is to then check tSC to see if X is a stream or string and then work from there.



I've tried to reproduce this problem using GetValueAt("DataSet.(0042,0011)") and this gives me a stream object from which I can read all the bytes in my sample (about 75K).

If you're using str.Read() to get the bytes from the stream you should use str.Read(str.Size) - with just Read() you only get ~32K bytes.

Andrew Cheshire

That's odd - when I am using GetValueAt("DataSet.(0042,0011)"), it is returning a string and not a stream object.

I have an open ticket with WRC to see what's going on. I'm 99% sure this is user error, but we'll see.