Is it possible to sort resources that have a date by date in ascending or descending order ? Pagination ?

For resources that actually have a date, is it possible to get the fetched results returned sorted by their date. That could be done relatively easily by post-processing the results after they are fetched, but just wondering if there is a feature in the REST API that allows for that ?

Also, what about pagination of results ? I see that you can LIMIT the number of results that are retrieved, and you can probably narrow the query if too many results are expected. If you are using a MySQL or Postgres database, is it possible to just query the database to get results that way. That provides a little more flexibility. If so, is there a library or documentation somewhere about how to build queries using the Orthanc database. There are resources an storage area tables in the database, but it isn’t clear how the database is designed so that queries can be constructed.

Thank you.

/sds

Another somewhat related question. Is it possible to retrieve just some subset of fields for a resource ? For instance, can Orthanc return just the “MainDicomTags” for a study and omit the Instances, etc.

{
“ExpectedNumberOfInstances”: null,
“ID”: “8d9c575f-5d6b4f48-73166d6d-e4f50f19-f2666dfd”,
“Instances”: [“47885115-9291990a-a4e1cc8e-7b85ff70-c6118b4f”, “9fb374ae-392b102c-ef9c42bf-96fad9c7-dbf306fa”, “8b42ecfd-a8ac16d6-f310906a-ab894563-2f097cfe”, “c4684d8f-81a8d739-4aced882-c837bd09-ac62be0d”, “0d037987-41869275-2fcab520-63aa8abe-9702fdd6”, “50cbd8cc-732ee58b-c524aa7d-5b472ed4-3f7c4a30”, “9ac09eb9-f0a5e256-25379f99-02ed65e7-25e67904”, “0a9211cf-56389b4c-2b394136-a5ecd0dc-876e64f2”, “688422da-e4cbf157-0691eb7f-17326ce7-6f2dff23”, “feacfa5b-28d5c420-b7ca7c5b-e25a5e1b-e99f8c81”, “b78046b5-6ae47222-e2bc45df-4bab4608-469f3744”, “b539040b-b3ef68e1-b42d061c-e6f4f84b-a3c05854”, “68b32988-ee66a6b4-49d30eb9-5d8d6660-0a8d816b”, “893f1117-ba09e53f-7365269a-939bcc10-99cbef34”, “30bccae5-3cb6b072-575eac1e-d6e9a58c-cc68ad75”, “8bc43896-3fddaae3-a96ede07-55dba49d-11129cf0”, “01b2da06-b7920bb5-63ed8d6e-9eef2ddb-809458e4”, “3639b74a-23a600c4-911b1e21-c7e21c5c-8bc6a4a4”, “c4dce793-b08c5962-3970b738-94253f91-98cc753d”, “a2a82001-c4cf2a19-c36589ac-72eb05c3-5824966d”, “094d2587-8e35713a-bdd216ca-70ce3467-1b9a5c19”, “a943d7e2-d54c331c-b770e882-695a1f96-7ea99276”, “e88a5e6b-7732efe4-b8726638-ee571c90-bc5c60ff”, “7f01197d-1cf30bc2-8a2e7d14-46d38657-cbfda835”, “12721d77-5025838f-04a79a5d-055bc77c-685dc4ff”, “109907ea-f9b0dcf0-ba614954-a037514a-d4a6e167”, “f84337b9-506aeba1-398f922b-8b6718da-fb78e27d”, “3d1446b0-258f0716-48901d14-ce7c015a-4e97ab3d”, “87523fd4-786e3118-b36bf609-ff420ea2-3ebb3f8d”, “86d24687-3ba30780-3a5849a3-444fd1eb-f36f4170”, “03bb8cbe-b3029fbc-0556a51a-c693b12a-f0593d9a”, “e996723d-bb5581ab-77eaebb6-a7499012-323c28f4”, “4519998e-04eb5e9c-2d50153b-3f0b561d-e065f38a”, “62173074-242f1aac-d6684e37-f6b8335f-e7733dcd”, “cac5d46b-e78de027-1e0443d3-b55b7f44-178c63a6”, “a639c69d-a2da3783-c2ea99bd-24ae1624-fc56d684”, “c7009ae6-ad36446c-cd4d431f-c8e8008d-acfeb6dd”, “685f096b-8eee5e9c-4bc12238-d4885ea4-f5ca4d92”, “ac79943a-3c3ad1df-a770f2a1-b6c403a9-92762dbd”, “3c36db9d-2b2dc5d2-0f33b518-a47e6a75-9f76a913”, “478694f5-42e61483-2302bed7-fd07f9e6-d90ebcf8”, “8dfcd856-8eb20047-40d7141b-d48e6365-ac903132”, “c3568a1a-c6dc8c2e-f86e0617-66da6ba9-a65bf068”, “d49e2d04-3895b379-401b8de7-a1760d73-4c03b36c”, “6364bb05-4ac318a2-e63304be-1bee2fb2-27444d8e”, “cd25a3a0-6757c8dc-5a228f34-28d5b86e-fe111cd3”, “77437505-f02ad56a-76e95ba3-69b7bd99-7cd24bf5”, “cbe7556e-ba77ef8c-32325d4d-13d8a2ff-6a5eed06”, “76dd8112-fb183c5c-27d4aadb-301fb1f5-b55a086b”, “3333b541-9a181a6f-6b821188-1b53ad9a-4298fe9b”, “79f500ce-59ed5076-52e65591-77e62191-66625102”, “aa9fbf1b-38146c4d-b75d9061-2067d0f2-c3939819”, “d868189c-45c03bb9-c624caf9-776063cd-b9e4648e”, “773a70ff-b2fa3d20-9e2c7469-99926354-baf98045”, “4793e217-eaeb49d1-f8ad20e7-2a490712-ee228da4”, “d169ff7f-7965ed83-1f88afcb-c9b77c98-fd66f9fc”, “e6b9ac33-9953d7d6-60833155-abd649e5-97e98794”, “8b015b07-4c1d665c-5863d73c-40f97133-415bfb86”, “306722ef-b1414d3f-a3de920d-ab770fce-c478716a”, “47650db6-b86acee5-c6a1d096-bd80f40c-e9f11a77”, “97784b96-2d821bec-9f91c19b-13811a40-85fdc115”, “6f4d0443-6f57539c-9c6cc708-b7a33e1b-c567743f”, “4c4d2548-a0896028-f32ddbd2-1be303ff-62799ff4”, “4a89864e-00e11e38-65642861-b2c247c1-1f3af630”, “438b5825-82f273e3-fa99ba39-320e5e13-bde0ba63”, “cd4f6cf6-1ff034af-76dc7dd7-083bfd19-85d0222b”, “17bebfd7-6954b28c-e7c4a4e1-b933ea1e-4872fca9”, “1a90756b-7dd641bc-6330a32a-c1b9b3a9-2c360fc4”, “264ae18f-6f5e3983-43ce347d-df3e5a4e-267ca971”, “941ce399-f12599f8-fc9bb9de-c87cac1d-3e97c0a2”, “bc952a19-38297966-57975c32-576814f0-d9d1513a”, “4dda04ec-fa81e3c2-541a6a2b-90c25f37-1441912e”, “adf51696-70ecf9ce-b7fd4724-554c7564-d0688426”, “7a067fa0-c7bb4db1-145de4c2-010d4870-705a9c26”, “0bb1b300-37d858fb-27f63072-6b7aed74-481d9dfc”, “f1d9d68d-80c9010c-648c61a2-64c3df65-f1aae1bc”, “69b25185-74675d5c-4a0014cc-e126de4b-399d8ff1”, “463924f7-8fbd2197-6ef57e85-c001515b-59671c57”, “8f4c8023-fc4e80d6-6ad777ae-97924326-d48ae87b”, “c87d3c94-9aef80f8-37554f78-86c91cd8-ebeb2e78”, “8a4c9a2e-6cefd3b1-3c8e962c-0c467ff7-4a2d32ee”, “5c9b9260-dbff3486-ecf2cafd-310b4794-55d2d45d”, “bd126d4b-95168faa-98ddca61-bcfb58e6-750ea87e”, “4106797c-3cebbc11-7afbe8dc-03e6650a-2b90b5d9”, “0645ffa7-3256764e-8514517c-350eccf2-0d203dd6”, “ee937b72-f496dbb7-57012bbe-2a33f46d-dc96377e”, “cdd2825f-45d76cbe-8d865262-f0644ce1-1f246b49”, “7290683d-1b17c2ce-3cc157ad-8f910154-acb9eb1b”, “e89b55a4-6b7ba480-5f0780f2-30e55bbd-e0e38455”, “d98e2be0-bf28ef37-0603f2e6-83eec3d9-f9c84968”, “4740cc56-7401efec-5e6b3e93-a20dc2f5-f2e4e5c9”, “3ed71c15-3e516b83-b382cdcc-f972a3de-fe21adb3”, “30b98f0a-1564d0e2-098a4969-ce2dc1f4-cd2c1bf6”, “ef87bc83-274e9a2f-bc113f81-2ac8c0fe-7a4b3f4f”],
“IsStable”: true,
“LastUpdate”: “20200503T034938”,
“MainDicomTags”: {
“BodyPartExamined”: “HEAD”,
“ImageOrientationPatient”: “0.99665302\0.081747003\0\0\0\-1”,
“ImagesInAcquisition”: “94”,
“Manufacturer”: “ESAOTE”,
“Modality”: “MR”,
“ProtocolName”: “Kopf RL”,
“SequenceName”: “3D SST1”,
“SeriesDate”: “20160418”,
“SeriesDescription”: “0\u00b0 - 3D SST1 cor esaote”,
“SeriesInstanceUID”: “1.3.76.2.1.1.4.1.3.5310.511615220”,
“SeriesNumber”: “2”,
“SeriesTime”: “122020”,
“StationName”: “G-Scan Brio”
},
“ParentStudy”: “307faeb2-06c232d3-2c5e3a02-77c0725f-c8f52be0”,
“Status”: “Unknown”,
“Type”: “Series”
}

Regarding paging and sorting, check out the Orthanc Book:

https://book.orthanc-server.com/faq/improving-interface.html

“Non-technical audience (physicists, patients, administrative staff…) might expect an user interface that is more user-friendly than Orthanc Explorer, and/or that integrates more features (such as language translations, sorting resources, access control lists, tagging images, beautiful layout, tunable anonymization, modification of instances, paging if many patients, handling of timeouts, login/logout, Web diffusion to patients/physicians…).”

To extend the REST API (e.g. to implement sorting or filtering), implement a C/C++ plugin or a Python plugin:
https://book.orthanc-server.com/developers/creating-plugins.html

https://book.orthanc-server.com/plugins/python.html#extending-the-rest-api

Regarding limiting the results, the “/tools/find” URI has a “Limit” option:
https://book.orthanc-server.com/users/rest.html#performing-finds-within-orthanc

Regarding direct access to the MySQL/PostgreSQL, you should never do so:
https://book.orthanc-server.com/faq/orthanc-storage.html#direct-access

Regarding limiting the results, the “/tools/find” URI has a “Limit” option:
https://book.orthanc-server.com/users/rest.html#performing-finds-within-orthanc

I saw that. “I see that you can LIMIT the number of results that are retrieved . .”

Regarding direct access to the MySQL/PostgreSQL, you should never do so:
https://book.orthanc-server.com/faq/orthanc-storage.html#direct-access

To clarify using the MySQL/PostgresSQL database. Just wondering if it is “OK” to perform read-only queries (SELECT statements) using those databases ? No writing, or does that interfere with Orthanc’s operations on those databases due to locks, potentially ? The documentation talks mostly about SQLite databases. It still might be useful to be able to perform SELECT queries through the database (i.e. to sort them by date, age, etc.). An alternative is to take the results from a REST API calls, convert to an array and then sort by a key value.

Also, what happens if you try to store the same study twice (i.e. a duplicate, same study_uid. Does Orthanc just create another instance with a different uuid, or does that possibly cause a problem ?

Thank you.

Regarding direct access to the MySQL/PostgreSQL, you should never do so:

https://book.orthanc-server.com/faq/orthanc-storage.html#direct-access

To clarify using the MySQL/PostgresSQL database. Just wondering if it is “OK” to perform read-only queries (SELECT statements) using those databases ? No writing, or does that interfere with Orthanc’s operations on those databases due to locks, potentially ? The documentation talks mostly about SQLite databases. It still might be useful to be able to perform SELECT queries through the database (i.e. to sort them by date, age, etc.). An alternative is to take the results from a REST API calls, convert to an array and then sort by a key value.

Do this at your own risk.

Also, what happens if you try to store the same study twice (i.e. a duplicate, same study_uid. Does Orthanc just create another instance with a different uuid, or does that possibly cause a problem ?

https://book.orthanc-server.com/faq/orthanc-ids.html