REST API, how to get instance PNG after query?

Hi,

I am trying to query Orthanc via REST for matching DICOM instances and load the PNG images of these instances afterwards.

http://book.orthanc-server.com/users/rest.html#performing-a-query-on-a-remote-modality

shows how to send the query.

That works for me with the expected result

From there I can also request more infos about the query result via Path/answers etc.

But how can I access the preview images of these DICOM instances from there
and which retrieve options are available to get them in desired resolution or size?

I read this here http://book.orthanc-server.com/users/rest.html#downloading-images
but that works only if I give it a uuid that the Webviewer uses.

There seems to be a missing piece between IDs returns via query and the uuids to get the PNGs.
But might be that I don’t see the wood for the trees.

Thanx
Torsten

I might be wrong but I think you may be mixing up two parts. I do not think you are able to view remote DICOM files on other modalities/PACS, but only on the local install of Orthanc. The ID you are getting when you do a query on a remote modality is not an instance ID, but a query ID, which may return several results and is temporary.
Orthanc uses ID’s for queries, patients, studies, series, and instances.

So for example you would do a find against the Orthanc server, retrieve the Orthanc ID’s of instances, then open them as JPEG with each instance:
curl --request GET --url http://localhost:8042/instances/f39c8903-00250477-0df3caed-abc56967-472ed57a/preview

So to retrieve as a image, you would find on the remote modality, move to the Orthanc server, then retrieve as an Image.

I am not querying modalities but Orthanc itself. For that, I have added Orthanc as DICOM modality in Orthanc.config file.
That allows to query as shown in my screenshot - and that is working as expected.

The result allows me to GET the tags and meta data of the instance with …/answers/0/content
but I need to extract the ID of the instance with which I can then get the preview - and I have no clue how to get it from the query result.

So, here is what I am doing in detail:

do the query on instance level, query for instances of patient named "Potter*:

$ curl --request POST \
  --url http://localhost:8042/modalities/local/query \
  --data '{"Level":"Instance","Query": {"PatientID":"","StudyDescription":"","PatientName":"Potter*"}}'

this delivers

{

“ID” : “1B249CFC-1E71-4661-9A18-0E38D2D42C18”,

“Path” : “/queries/1B249CFC-1E71-4661-9A18-0E38D2D42C18”

}

The ID is not an instance ID but the ID of the query result.

I then use the “Path” from above in order to get the query results:

$ curl --request GET \
  --url http://localhost:8042/queries/1B249CFC-1E71-4661-9A18-0E38D2D42C18

this delivers

[ “answers”, “level”, “modality”, “query”, “retrieve” ]

I have tried them all

/retrieve delivers nothing

/answers delivers an array like [“0”, “1”, “2”,…“389”]

/answers/0/ delivers [ “content”, “retrieve” ]

/answers/0/retrieve delivers nothing

/answers/0/content delivers this here

{

“0002,0003” : {

“Name” : “MediaStorageSOPInstanceUID”,

“Type” : “String”,

“Value” : “1.2.392.200036.9125.0.19950720112207”

},

“0008,0005” : {

“Name” : “SpecificCharacterSet”,

“Type” : “String”,

“Value” : “ISO_IR 192”

},

“0008,0018” : {

“Name” : “SOPInstanceUID”,

“Type” : “String”,

“Value” : “1.2.392.200036.9125.0.19950720112207”

},

“0008,0050” : {

“Name” : “AccessionNumber”,

“Type” : “String”,

“Value” : “127”

},

“0008,0052” : {

“Name” : “QueryRetrieveLevel”,

“Type” : “String”,

“Value” : “INSTANCE”

},

“0008,1030” : {

“Name” : “StudyDescription”,

“Type” : “String”,

“Value” : “”

},

“0010,0010” : {

“Name” : “PatientName”,

“Type” : “String”,

“Value” : “POTTER^HARRY”

},

“0010,0020” : {

“Name” : “PatientID”,

“Type” : “String”,

“Value” : “000001”

},

“0020,000d” : {

“Name” : “StudyInstanceUID”,

“Type” : “String”,

“Value” : “127”

},

“0020,000e” : {

“Name” : “SeriesInstanceUID”,

“Type” : “String”,

“Value” : “1.2.392.200036.9125.0.199302241758.16”

}

}

but I don’t see how I can GET the instance ID that will allow me to load the preview then with

$ curl --request GET \
  --url http://localhost:8042/instances/[ID]

I am still somewhat new to Orthanc so I may be wrong:
I think querying Orthanc that way will work, I think it will just assume it is querying a modality. And it wont tag a ID to instances on remote modalities. If you use the find, it directly queries the data on Orthanc and will retrieve the info you need. Here is an example below, it will return all the instance ID’s:

curl --request POST --url http://localhost:8042/tools/find --data ‘{“Level”:“Instance”,“Query”:{“Modality”:“CR”,“StudyDate”:“20180323-”,“PatientID”:“*”},“Limit”:50}’

Thank you Bryan, that was the missing piece for me.
I wasn’t aware about the difference between the two query types.
With /tools/find it works now as expected.

Maybe something worth to mention in the Book of Orthanc.

Yeppers. I’ve only recently used find myself, so never knew about it either until searching some example code so I’ll add it to the find section soon.