Раньше ничем таким не занимался, знания о DICOM заканчиваются на том, что это формат медицинских изображений…
На работе есть несколько медицинских устройств, которые обмениваются снимками с компа оператора на комп врача.
На каждом оборудовании есть своя программа и на станциях врачей своя.
Решил попробовать сделать единое хранилище.
Конечно, можно купить и платные продукты, но это не наш метод.
Поиск выдал Orthanc, система у меня Debian 10, так что решил поставить из репозитория:
apt-get install Orthanc
Установил, поправил конфиг для того что бы зайти в WEB, загрузил несколько картинок…
В последних версиях пользователи хранятся тут :
credentials.json
{
/**
* Sensitive configuration options. This file must *not* be
* publicly-readable. It must only be readable by the users that run
* the "orthanc" service.
**/
// The list of the registered users. Because Orthanc uses HTTP
// Basic Authentication, the passwords are stored as plain text.
"RegisteredUsers" : {
"alice" : "alicePassword"
"admin" : "adminPassword",
}
}
Включение http сервера и авторизации тут:
Orthanc.json "HttpServerEnabled" : true, "AuthenticationEnabled" : true,
Что-то мне не понравился стандартный web viewer…
Решил прикрутить viewer от Osimis.
скачиваем:
wget http://orthanc.osimis.io/lsb/plugin-osimis-webviewer/releases/1.2.0/libOsimisWebViewer.so
нужно посмотреть → http://orthanc.osimis.io/lsb/plugin-osimis-webviewer/releases/1.3.1/libOsimisWebViewer.so
по умолчанию подгружаются все плагины находящиеся в папке /usr/share/orthanc/plugins
поэтому директиву Plugins править не нужно.
скаченную библиотеку надо поместить в папку: /usr/share/orthanc/plugins
и перезапустить orthanc.
// Whether remote hosts can connect to the HTTP server
"RemoteAccessAllowed" : false, - исправить на true что бы зайти в WEB
"Plugins" : [
"/home/user/ libOsimisWebViewer.so r.so",
]
TITLE AE -сервера, собственно куда отправляются снимки И кодировка в которую они будут преобразованы «DefaultEncoding» : «Windows1251»,
// The DICOM Application Entity Title "DicomAet" : "ORTHANC", // Check whether the called AET corresponds to the AET of Orthanc // during an incoming DICOM SCU request "DicomCheckCalledAet" : false, // The DICOM port "DicomPort" : 4242, // The default encoding that is assumed for DICOM files without // "SpecificCharacterSet" DICOM tag, and that is used when answering // C-Find requests (including worklists). The allowed values are // "Ascii", "Utf8", "Latin1", "Latin2", "Latin3", "Latin4", // "Latin5", "Cyrillic", "Windows1251", "Arabic", "Greek", "Hebrew", // "Thai", "Japanese", "Chinese", "JapaneseKanji", "Korean", and // "SimplifiedChinese". //"DefaultEncoding" : "Latin1", "DefaultEncoding" : "Windows1251",
WEB-интерфейс тут http://ваш ip:8042/app/explorer.html
Подключение к СУБД:
apt-get install default-mysql-server default-mysql-clietn defaultlt-libmysqlclient-dev orthanc-mysql
Увеличиваем размер блока данных:
mcedit my.cnf max_allowed_packet = 128M
создаем пользователя и бд, подключаемся:
mcedit /etc/orthanc/mysql.json
cat /etc/orthanc/mysql.json
{
/**
* Configuration to use MySQL or MariaDB instead of the default
* SQLite back-end of Orthanc. You will have to install the
* "orthanc-mysql" package to take advantage of this feature.
**/
"MySQL" : {
// Enable the use of MySQL to store the Orthanc index?
"EnableIndex" : true,
// Enable the use of MySQL to store the DICOM files?
"EnableStorage" : true,
// Parameters of the MySLQ database
"Host" : "localhost",
"Port" : 3306,
"Database" : "orthanc",
"Username" : "orthanc",
"UnixSocket" : "/var/run/mysqld/mysqld.sock",
"Password" : "dDE4dkULEYrbBZxc",
// Optional: Disable the locking of the MySQL database
"Lock" : true
}
}
Контроль доступа и отправка на другие модальности:
Orthanc.json
"LuaScripts" : [
"/etc/orthanc/lua/access.lua",
"/etc/orthanc/lua/send.lua"
],
"sample" : [ "AE_TITLE", "192.168.1.235", 4006 ]
Lua:
Разрешения выполнять запросы к Orthanc, с помощью этого скрипта можно разграничить права доступа к web интерфейсу Orthanc
cat access.lua
function IncomingHttpRequestFilter(method, uri, ip, username, httpHeaders)
-- Only allow GET requests for non-admin users
if method == 'GET' or method == 'POST' then
return true
elseif username == 'admin' then
return true
else
return false
end
end
Можно по ip
function IncomingHttpRequestFilter(method, uri, ip, username, httpHeaders)
if method == 'GET' and (username == 'user' or username == 'admin') then
-- Read-only access (only GET method is allowed)
return true
elseif username == 'admin' and ip == '127.0.0.1' then
-- Read-write access for administrator (any HTTP method is allowed on localhost)
return true
else
-- Access is disallowed by default
return false
end
end
С помощью этого скрипта можно отправлять снимки которые пришли в Orthanc на другие DICOM сервера или на рабочие станции врачей.
cat send.lua
function OnStoredInstance(instanceId, tags, metadata)
SendToModality(instanceId, 'sample')
end
С помощью этого скрипта можно разбирать изображение которые приходят на Orthanc и маршрутизировать их на другие сервера.
cat /etc/orthanc/lua/send.lua
function OnStoredInstance(instanceId, tags, metadata)
local Modality = tags['Modality']
if string.find(Modality, 'CR') ~= nil then
SendToModality(instanceId, 'sample')
elseif string.find(Modality, 'MR') ~= nil then
SendToModality(instanceId, 'sample')
end
end
перезапускаем:
services orthanc restart
Удаление старых записей
$ curl --user admin:password http://localhost:8042/tools/find -d '{"Level":"Study","Query":{"StudyDate":"20120101-20121231"}}'
[
"6e2c0ec2-5d99c8ca-c1c21cee-79a09605-68391d12",
"ef2ce55f-9342856a-aee23907-2667e859-9f3b734d"
]
$ curl -X DELETE http://localhost:8042/studies/6e2c0ec2-5d99c8ca-c1c21cee-79a09605-68391d12
$ curl -X DELETE http://localhost:8042/studies/ef2ce55f-9342856a-aee23907-2667e859-9f3b734d