Attaching PDF file as DICOM series under specific study - orthanc API

Hi all!

I would like to use orthanc’s API to:

a) dicomize a PDF file
b) upload dicomized PDF file to orthanc but attached as series under a specific study

I am not sure if this can be directly done using the process described here:
https://book.orthanc-server.com/users/advanced-rest.html#attaching-pdf-file-as-dicom-series

So, i want to dicomize and upload my pdf as a series, under patient’s “32780” specific study with studyInstanceUID “1.2.840.113619.2.25.4.2147483647.1584958560.152”:

Capture.JPG

I am trying to find the “correct” json data string to achieve that. I have tried the following:

create the json data

  1. $params = @{Tags = @{PatientID = “32780”;Modality = “MR”};Content= “data:application/pdf;base64,$fileInBase64”}
  2. $params = @{Tags = @{PatientID = “32780”;StudyInstanceUID = “1.2.840.113619.2.25.4.2147483647.1584958560.152”;Modality = “MR”};Content= “data:application/pdf;base64,$fileInBase64”}
  3. $params = @{Tags = @{StudyInstanceUID = “1.2.840.113619.2.25.4.2147483647.1584958560.152”;Modality = “MR”};Content= “data:application/pdf;base64,$fileInBase64”}
  4. $params = @{Tags = @{PatientID = “32780”; StudyID = “14168”; Modality = “MR”};Content= “data:application/pdf;base64,$fileInBase64”}

but none of them seems to work.

In cases (1), (4) the dicomized pdf is getting uploaded, under the patient with patientID = “32780” but as a “new” study (different studyInstanceUID)
In cases (2), (3) where i tried to use the studyInstanceUID to attach the dicomized PDF under the study “1.2.840.113619.2.25.4.2147483647.1584958560.152” i am getting:

Invoke-RestMethod : {
“Details” : “StudyInstanceUID”,
“HttpError” : “Bad Request”,
“HttpStatus” : 400,
“Message” : “Trying to override a value inherited from a parent module”,
“Method” : “POST”,
“OrthancError” : “Trying to override a value inherited from a parent module”,
“OrthancStatus” : 2020,
“Uri” : “/tools/create-dicom”
}
At line:1 char:10

  • $reply = Invoke-RestMethod http://localhost:8042/tools/create-dicom - …
  • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
  • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

So, is it possible to directly attach the dicomized pdf under specific patient & study in orthanc? If yes what am i missing on the JSON string?

Thanks!

Hi again,

by searching a little bit more on the net (https://bitbucket.org/sjodogne/orthanc-tests/commits/cccf697a4e13da02cb7d0dd3dd3f69085f55756a) i found that I can attach the dicomized pdf (instance) under my study by using the “Parent” parameter in my JSON like:

$params = @{Tags = @{PatientID = “32780”;Modality = “MR”;SOPClassUID = “1.2.840.10008.5.1.4.1.1.104.1”;SeriesDescription = “PDF report”};Content= “data:application/pdf;base64,$fileInBase64”;Parent = “c00825de-2c6fc8ef-5a564ae5-b2fbb3db-12a54edf”}

Is there any resource or documentation listing all possible parameters of JSON string to be used with /tools/create-dicom?

Thanks!

Thanasis

Hi Thanasis,

Sorry, we’re not that good at documenting the API. Any contribution is welcome in that sense.

So right now, the best source of information is usually the code itself :frowning: or the integration-tests that are more readable since everything is in a single file:
https://hg.orthanc-server.com/orthanc-tests/file/tip/Tests/Tests.py Just look for “/create-dicom”…

Hi Alain,

Thanks for your response!

Thanks a lot for the info!

I can understand that keeping up the docs with something constantly growing is challenging :slight_smile: so no prob!

Very Helpful. I was / am looking for the same functionality with PHP. Have not tried that, but tried from the command line and that works:

e.g.

(echo -n ‘{“Tags” : {“Modality” : “OT”, “SeriesDescription”:“PDF REPORT”},“Content” : "data:application/pdf;base64,’; base64 “/Users/sscotti/Desktop/HL7_Messaging_v251_PDF/IP Copyright and Trademarks.pdf”; echo ‘", “Parent”:“6efb3ff2-4cd16ca1-35cdb247-2d1c5f78-d6ba584e”}’) > /tmp/foo

cat /tmp/foo | curl -H “Content-Type: application/json” -d @- http://localhost:8042/tools/create-dicom

where parent is the uuid for the study.

Should be easy to implement in PHP