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

831 views
Skip to first unread message

Thanasis Iliopoulos

unread,
May 27, 2020, 3:46:43 AM5/27/20
to Orthanc Users
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:

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!

Thanasis Iliopoulos

unread,
May 27, 2020, 5:20:23 AM5/27/20
to Orthanc Users
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

Alain Mazy

unread,
May 29, 2020, 3:51:36 AM5/29/20
to Thanasis Iliopoulos, Orthanc Users
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 :-( or the integration-tests that are more readable since everything is in a single file:

 

--
You received this message because you are subscribed to the Google Groups "Orthanc Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orthanc-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orthanc-users/a6559195-a4c0-42c8-95de-4e20b4ae18d2%40googlegroups.com.


--

Alain Mazy / Orthanc-Studio Manager & Software Developer
a...@osimis.io / +32 494 31 67 27

Osimis

OSIMIS S.A. 
Quai Banning 6BE-4000 Liège 
www.osimis.io

Twitter LinkedIn


Thanasis Iliopoulos

unread,
May 29, 2020, 4:17:53 AM5/29/20
to Orthanc Users
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 :) so no prob!
To unsubscribe from this group and stop receiving emails from it, send an email to orthan...@googlegroups.com.

Stephen Douglas Scotti

unread,
Jun 6, 2020, 10:50:11 PM6/6/20
to Orthanc Users
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


Reply all
Reply to author
Forward
0 new messages