Location of study files - postgresql and disk files

First,
i am new here so “Hello everybody”.

The question:

  1. Where in PostgreSQL Database i can find location of directory containing data files of specific patient. ? ( i am storing only meta, the pictures are on disk)

  2. How to find oldest Studies ?

I cannot find any info about table structure.
I am using Osimis installation for windows.

What i want to achieve is to archive some old data to LTO Tape and free space on my array.

Or maybe you have any other idea than manual archiving to LTO.

Greetings
Krzysiek

Hi, Krzysiek!

And welcome to the Orthanc Users mailing list!

  1. Since your images are stored on disk, you should know first the location of the base image directory. This is the “StorageDirectory” configuration option. If this is a relative directory (like “OrthancStorage”) then the full path is resolved to the current working directory. It will depend on where you’re starting Orthanc from. If it is an absolute path (like “/opt/orthanc/storage” or “C:\Orthanc\Storage”) then it’s resolved already.
    1.1. Inside the storage directory subfolders are resolved based on each images hash. For example, if a certain image unique identifier is e70e0944-5742-11ea-a55c-0fa4d3fba35b and the storage directory is /opt/orthanc/storage, then that image will be stored as /opt/orthanc/storage/e7/0e/e70e0944-5742-11ea-a55c-0fa4d3fba35b. Note that Orthanc creates a prefix with the ID’s first four characters (in this case, e70e) and splits them to create a two level hierarchy.
  2. If by oldest you mean the first study to be stored in Orthanc, then all you have to do is check the /changes URL (like https://localhost:8042/changes) and look for the first occurrence of [“ChangeType” : “NewStudy”]. If, on the other hand you’re looking for the oldest StudyDate, then I’m not sure how to do it properly, but I have a wild guess. I would do some sort of binary search (using the /find URL) given I have an idea of how old that study is (described in [2.2]).
    2.2. For instance, query for last year. If there are results, then query for the first semester, otherwise query for the second one. Then repeat this splitting process until you have a small enough set of answers (you should use the REST API for this), small enough for it to be worth looking at each result. But since this is a (very) wild guess, then it’s probably neither optimal nor the best solution.

Since you want to back old data on a LTO Tape and assuming backed up data would be erased from Orthanc, I’d recommend the creation of a plugin that:

  1. Use the /find URL to determine a set of studies to backup. This should be straight forward since backup requirements usually tell us to backup stuff older than a certain threshold.
  2. For each study found, download it with the /studies/[study-hash-id]/archive GET URL, then erase it with the /studies/[study-hash-id] DELETE URL.
  3. Save the downloaded studies to a unique directory
  4. Done

You can do something else like getting the study metadata before erasing the study from Orthanc so you can properly name the resulting ZIP archive. That way it’ll be trivial to recover the ZIP file should the need arise.

Hope this helps. Let us know if you have further questions.

Best,

Hi,
i have not expected such fast and detailed info. :slight_smile:

Thank you so much.

Now i will try to absorbe and use this knowledge.

Thanks again.

Greetings
Kris