Archive studies to NAS share

248 views
Skip to first unread message

Юрий Чередничок

unread,
Dec 16, 2021, 6:57:53 AM12/16/21
to Orthanc Users
Hi, Orthanc Team!

Looking for a best way to archive studies to archive NAS from Orthanc

Need to be archived:
<YEAR>
       <MONTH>
                <DAY>
                       <"PatientID1" - "PatientName1">.zip
                       <"PatientID2" - "PatientName2">.zip
                       .....

I can studies for a day by
curl -X POST http://localhost:8042/tools/find -d '{"Level":"Study","Expand":false,"Query":{"StudyDate":"20211215-20211215"}}'

PatientID and PatinentName can found by

and can get study archive by

BUT I need automate this process.

Any suggestions?

Best regards!


Sébastien Jodogne

unread,
Dec 16, 2021, 9:26:20 AM12/16/21
to Orthanc Users
Hello,

You might be interested in the following sample Python script that is part of the Orthanc source distribution:

You could also have a look at the WebDAV support:

Sébastien-

Юрій Череднічок

unread,
Dec 16, 2021, 10:58:31 AM12/16/21
to Orthanc Users
Hello!

Thanks for Python script.

Trying it at Debian 11
1.
:~$ /usr/bin/python3 /home/dicom/ArchiveStudiesInTimeRange.py
  File "/home/dicom/ArchiveStudiesInTimeRange.py", line 39
    print '"%s" is not a valid date!\n' % date
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('"%s" is not a valid date!\n' % date)?

modified to print('"%s" is not a valid date!\n' % date)
then run and got error 2
2.
:~$ /usr/bin/python3 /home/dicom/ArchiveStudiesInTimeRange.py http://10.21.25.250:8042/ 20211215 /srv/irpen-synology/
Traceback (most recent call last):
  File "/home/dicom/ArchiveStudiesInTimeRange.py", line 27, in <module>
    import RestToolbox
ModuleNotFoundError: No module named 'RestToolbox'

put it same folder as ArchiveStudiesInTimeRange.py
run again and got error 3:

3. TypeError: a bytes-like object is required, not 'str'

:~$ /usr/bin/python3 /home/dicom/ArchiveStudiesInTimeRange.py http://10.21.25.250:8042/ 20211214 20211215 /srv/irpen-synology/
Traceback (most recent call last):
  File "/home/dicom/ArchiveStudiesInTimeRange.py", line 87, in <module>
    filename = filename.encode('ascii', errors = 'replace').translate(None, r"'\/:*?\"<>|!=").strip()
TypeError: a bytes-like object is required, not 'str'

:(
четвер, 16 грудня 2021 р. о 16:26:20 UTC+2 s.jo...@gmail.com пише:

Юрій Череднічок

unread,
Dec 17, 2021, 5:09:14 AM12/17/21
to Orthanc Users
Done it!

it need to be install python2 and all works fine!

Thanks to all!

четвер, 16 грудня 2021 р. о 17:58:31 UTC+2 Юрій Череднічок пише:

Sébastien Jodogne

unread,
Dec 17, 2021, 7:37:39 AM12/17/21
to Orthanc Users
Hello,

FYI, I have just fixed compatibility of this sample script against Python3 with the following changeset:

Sébastien-

Юрій Череднічок

unread,
Dec 30, 2021, 4:03:44 AM12/30/21
to Orthanc Users
Hello again.
Seems strange things

At Orthanc i can see 91 study, buy script archives 89

Без названия.png
Any ideas why?



пʼятниця, 17 грудня 2021 р. о 14:37:39 UTC+2 s.jo...@gmail.com пише:

Alain Mazy

unread,
Dec 30, 2021, 5:04:04 AM12/30/21
to Юрій Череднічок, Orthanc Users
You've imported 89 folders and you get 91 studies.  One folder may contain data from more than one study.

HTH,

Alain.

--
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/89e1f6b4-87d0-43cb-8564-7dd7df4e5b2bn%40googlegroups.com.

Юрій Череднічок

unread,
Mar 16, 2023, 8:28:08 AM3/16/23
to Orthanc Users
Hi all. Have a question: how correct send username and password to this python script?

got next exeption without credentials
Traceback (most recent call last):
  File "/home/urik/OrthancTools/scripts/ArchiveStudiesInTimeRange.py", line 61, in <module>
    for studyId in RestToolbox.DoGet('%s/studies' % URL):
  File "/home/urik/OrthancTools/scripts/RestToolbox.py", line 65, in DoGet
    raise Exception(resp.status)
Exception: 401



четвер, 30 грудня 2021 р. о 12:04:04 UTC+2 Alain Mazy пише:

Sébastien Jodogne

unread,
Mar 16, 2023, 12:36:45 PM3/16/23
to Orthanc Users
Hello,

You should be able to do so by adding a call to "RestToolbox.SetCredentials()", that is defined in the following file:

HTH,
Sébastien-

Юрій Череднічок

unread,
Mar 17, 2023, 11:18:28 AM3/17/23
to Orthanc Users
in these scripts
i can find autorization but i can't compile something working for archiving script.
=(
I'm not so strong in programming

Anyone who knows python able to help?

четвер, 16 березня 2023 р. о 18:36:45 UTC+2 Sébastien Jodogne пише:
Reply all
Reply to author
Forward
0 new messages