prehistory
One medical organization implemented solutions based on Orthanc PACS servers and Radiant DICOM client. During the setup, we found out that each DICOM client must be described in PACS servers as follows:
- Client name
- AE name (must be unique)
- A TCP port that is automatically opened on the client side and receives DICOM exams from the PACS server (i.e. the server sort of pushes them towards the client - initiating the connection first)
- IP Address
After setting up Radiant, clients received the following information for reflection - for each client, setting up the software with the above parameters led to the filling of the file pacs.xml, which was located in the user profile (path: %APPDATA%RadiantViewerpacs.xml). At the same time, the config of one client differed from another by at least two parameters (the AE-name is different for everyone, and the port is basically the same, except for terminal clients running on the same server - there the ports also had to be assigned different).
pacs.xml file example
For about half a year everything was fine, the system started working ... and then we got to "underwater stones":
- We need to put into operation several new PACS servers that will replace the old ones (where disk space began to run out). PACS servers in virtual machines, but this is not about that;
- We need to somehow centrally change the unique configurations (with two different parameters) on 200 machines (their number has been regularly increasing);
- Taking into account the growth rates of survey volumes, the decision is not needed one-time, but replicated and regular (for example, once every 1-3 months).
The choice of tools for solving the problem
Initially, there were attempts to find some solution that changed the pacs.xml file on the client side and made changes to the list of PACS servers without touching the AE name and TCP port settings. Windows clients at that time were based on both Windows XP and Windows 7 - so there were attempts to write something like that based on VBScript. But alas, it was not possible to master such a task, due to the complete lack of experience in writing something complex and complex in this language. Attempts to find and rewrite were also unsuccessful (here it should be noted that there was already a different plan in my head, so I didnβt hammer with VBScript for more than 3-4 hours).
In the end, I settled on the following solution:
- Collect by group policy all pacs.xml files in one place on any server in a network resource;
- Change files en masse (there was already experience in solving such problems - using Perl);
- Also, use group policies to update client settings.
Collecting Files Using Group Policy
The simplest part is that when a client logs into his profile, he executes a certain .bat file with his rights, which says:
echo off
If exist %APPDATA%RadiantViewerpacs.xml copy %APPDATA%RadiantViewerpacs.xml srv.test.localpconfigs$pacs-%COMPUTERNAME%-%USERNAME%.xml
Thus, pacs.xml files will be accumulated on the server in a hidden resource, the name of which contains information from which computer and from which user this config was copied.
The most difficult thing was to wait until this policy worked out for all users.
Changing Configurations with a Perl Script
We will need
The script itself turned out to be quite simple:
use XML::Writer;
# ΠΡΠΊΡΡΠ²Π°Π΅ΠΌ ΠΏΠ°ΠΏΠΊΡ Ρ ΠΎΡΡΠ΅ΡΠ°ΠΌΠΈ, ΠΎΠ±ΡΠ°Π±Π°ΡΡΠ²Π°Π΅ΠΌ ΡΡΠΏΠΈΡΠΎΠΊ (ΡΠ΄Π°Π»ΡΠ΅ΠΌ Π»ΠΈΡΠ½Π΅Π΅):
$report_dir = "C:Perl64WORKPACS-xml3";
opendir(DIR, "$report_dir") or die "ΠΠ΅ ΠΌΠΎΠ³Ρ ΠΎΡΠΊΡΡΡΡ ΠΏΠ°ΠΏΠΊΡ Ρ ΠΎΡΡΠ΅ΡΠ°ΠΌΠΈ!";
@report_files = readdir DIR;
shift (@report_files); # ΡΠ΄Π°Π»ΡΠ΅ΠΌ ΡΠΎΡΠΊΡ ΠΈΠ· ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΠΌΠ°ΡΡΠΈΠ²Π° (.)
shift (@report_files); # ΡΠ΄Π°Π»ΡΠ΅ΠΌ Π΄Π²Π΅ ΡΠΎΡΠΊΠΈ ΠΈΠ· ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΠΌΠ°ΡΡΠΈΠ²Π° (..)
# print "@report_files";
closedir(DIR);
# ΠΠ°ΡΠΈΠ½Π°Π΅ΠΌ ΠΎΠ±ΡΠ°Π±Π°ΡΡΠ²Π°ΡΡ ΡΠ°ΠΉΠ»Ρ - ΠΏΠΎ ΠΎΠ΄Π½ΠΎΠΌΡ Π·Π° ΡΠ°Π·. ΠΡΠΆΠ½ΠΎ ΡΡΠΈΡΠ°ΡΡ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ AET ΠΈ Π½ΠΎΠΌΠ΅Ρ ΠΏΠΎΡΡΠ° Π² ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅.
foreach $analiz_file (@report_files)
{
$full_path_to_file="C:Perl64WORKPACS-xml3".$analiz_file;
open (INFO, $full_path_to_file);
while ($line = <INFO>)
{
# ΠΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ $aet ΠΈ $port ΡΠΎΠ΄Π΅ΡΠΆΠ°Ρ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ XML ΡΠ°ΠΉΠ»Π°:
my ($other1, $aet, $other2, $port, $other3) = split /"/, $line, 5;
# ΠΡΠ»ΠΈ Π²ΡΡΡΠ΅ΡΠ°Π΅ΡΡΡ ΡΡΡΠΎΠΊΠ° listener - ΡΠΎ ΠΌΡ Π΄ΠΎΡΠ»ΠΈ Π΄ΠΎ Π½ΡΠΆΠ½ΠΎΠΉ ΡΡΡΠΎΡΠΊΠΈ ΠΈ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΡΠΌΠΈΡΠΎΠ²Π°ΡΡ Π½ΠΎΠ²ΡΠΉ XML:
if ($other1 =~ 'listener')
{
# Π€ΠΎΡΠΌΠΈΡΡΠ΅ΠΌ Π½ΠΎΠ²ΡΠΉ XML c Π½ΡΠΆΠ½ΡΠΌΠΈ ΠΏΠΎΠ»ΡΠΌΠΈ ΠΈ Π΄Π°Π½Π½ΡΠΌΠΈ:
my $writer = XML::Writer->new(OUTPUT => 'self', DATA_MODE => 1, DATA_INDENT => 2, );
$writer->xmlDecl('utf-8');
$writer->startTag('pacs');
$writer->startTag('listener', ae => $aet, port => $port);
$writer->endTag();
$writer->startTag('hosts');
$writer->startTag('host', name => 'MRT', ae => 'ORTHANC', ip => 'XX.YY.214.17', ts => '1.2.840.10008.1.2.1', port => '4242', maxassoc => '1', allpres => '0', search => '1', protocol => '1', searchcharset => '', wildcards => '3', carets => '0');
$writer->endTag();
$writer->startTag('host', name => 'KT', ae => 'ORTHANC2', ip => 'XX.YY.215.253', ts => '1.2.840.10008.1.2.1', port => '4242', maxassoc => '1', allpres => '0', search => '1', protocol => '1', searchcharset => '', wildcards => '3', carets => '0');
$writer->endTag();
$writer->startTag('host', name => 'R', ae => 'ORTHANC3', ip => 'XX.YY.215.252', ts => '1.2.840.10008.1.2.1', port => '4242', maxassoc => '1', allpres => '0', search => '1', protocol => '1', searchcharset => '', wildcards => '3', carets => '0');
$writer->endTag();
$writer->startTag('host', name => 'KT-20180501-20180831', ae => 'ORTHANC4', ip => 'XX.YY.215.251', ts => '1.2.840.10008.1.2.1', port => '4242', maxassoc => '1', allpres => '0', search => '1', protocol => '1', searchcharset => '', wildcards => '3', carets => '0');
$writer->endTag();
$writer->startTag('host', name => 'KT-20180901-20181130', ae => 'ORTHANC5', ip => 'XX.YY.215.250', ts => '1.2.840.10008.1.2.1', port => '4242', maxassoc => '1', allpres => '0', search => '1', protocol => '1', searchcharset => '', wildcards => '3', carets => '0');
$writer->endTag();
$writer->endTag('hosts');
$writer->startTag('presets');
$writer->endTag();
$writer->startTag('lastsearch', dt => '4', mfid => '1048592');
$writer->endTag();
$writer->endTag('pacs');
# ΠΠΎΠΌΠ΅ΡΠ°Π΅ΠΌ Π³ΠΎΡΠΎΠ²ΡΠΉ XML Π² ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ:
my $xml = $writer->end();
# ΠΠΎΠ΄Π³ΠΎΡΠ°Π²Π»ΠΈΠ²Π°Π΅ΠΌ ΡΠ°ΠΉΠ» Π΄Π»Ρ ΠΏΠ΅ΡΠ΅Π·Π°ΠΏΠΈΡΠΈ:
$rewritexml = $full_path_to_file;
# ΠΠ΅ΡΠ΅ΠΏΠΈΡΡΠ²Π°Π΅ΠΌ XML ΡΠ°ΠΉΠ»Ρ Π½ΠΎΠ²ΡΠΌΠΈ Π΄Π°Π½Π½ΡΠΌΠΈ:
open (NEWXML, ">$rewritexml");
print NEWXML $xml;
close (NEWXML);
}
}
}
The principle of its work:
- Open the directory where we have collected pacs.xml configurations from clients and put the list of files in a scalar array (@report_files);
- In the loop, we process one file at a time and read it line by line;
- Split each line into 5 parts using quotes as a delimiter;
- We find the line with the word listener and put data unique for each file (AE-client name and TCP port number) into two variables;
- After that, we simply form a new XML file, enter unique parameters into it, and then insert the required number of PACS servers with their parameters - those. that for which everything was started)
- We overwrite the new XML file on top of the old one.
It should be noted that in fact I use this script not completely automatically - in fact, I copy the collected configs to a separate directory and then, by running the script, I change them all together. Further selective check - and configs can be poured back on machines.
Distributing modified pacs.xml files to clients
The simplest thing that came to my mind was to make changes to the already working .bat file that collects configurations from clients and add the line:
If exist %APPDATA%RadiantViewerpacs.xml copy /Y srv.test.localpconfigsnew$pacs-%COMPUTERNAME%-%USERNAME%.xml %APPDATA%RadiantViewerpacs.xml
The final .bat file looks like this:
@echo off
If exist %APPDATA%RadiantViewerpacs.xml copy %APPDATA%RadiantViewerpacs.xml srv.test.localpconfigs$pacs-%COMPUTERNAME%-%USERNAME%.xml
If exist %APPDATA%RadiantViewerpacs.xml copy /Y srv.test.localpconfigsnew$pacs-%COMPUTERNAME%-%USERNAME%.xml %APPDATA%RadiantViewerpacs.xml
Conclusion
Such is "knee" solution. We have already tested it twice (in September 2018 and in February 2019), while the flight is normal. Of course, it does not update 100% of clients, but close to this value - we finish the rest remotely. Script by
Source: habr.com