📜 ⬆️ ⬇️

Change program settings while maintaining personal settings

Prehistory


In one medical organization, they implemented solutions based on Orthanc PACS servers and Radiant DICOM clients. During the setup, we found out that each DICOM client should be described in PACS servers as follows:


After setting up Radiant, the clients received the following information to think about - for each client, setting up software with the above parameters resulted in filling out the pacs.xml file, which was located in the user profile (path: % APPDATA% \ RadiantViewer \ pacs.xml ). At the same time, the configuration of one client differed from the other 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, too, ports had to be assigned different).

Example of the pacs.xml file at the link :
')
For about half a year everything was fine, the system started working ... and then the " pitfalls " reached us:


Solution below.

The choice of tools for solving the problem


Initially, there were attempts to find some solution that, on the client side, modified the pacs.xml file and made changes to the list of PACS servers without affecting the settings of the AE name and TCP port. Windows clients at that time were based on both Windows XP and Windows 7 - so there were attempts to write something based on VBScript. But alas, it was impossible 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 (it should be noted that there was already another plan in my head, so I didn’t bother with VBScript for more than 3-4 hours).

As a result, I settled on the following solution:


Collecting Files Using Group Policy


The simplest part is that when a client enters his profile, he, with his rights, executes a certain .bat file, in which it is written:

echo off If exist %APPDATA%\RadiantViewer\pacs.xml copy %APPDATA%\RadiantViewer\pacs.xml \\srv.test.local\pconfigs$\pacs-%COMPUTERNAME%-%USERNAME%.xml 

Thus, on the server in a hidden resource, pacs.xml files will be accumulated, in the name of which there is information from which computer and from which user the given config was copied.

The most difficult thing was to wait for all users to complete this policy.

Configuration changes using the Perl script


We will need Active Pertate under Windows from ActiveState, as well as the XML :: Writer module, which can be installed using the ppm install XML-Writer command.

The script itself turned out pretty simple:

 use XML::Writer; #    ,   ( ): $report_dir = "C:\\Perl64\\WORK\\PACS-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:\\Perl64\\WORK\\PACS-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:


It should be noted that in fact I use this script not completely automatically - in fact, I copy the collected configs into a separate directory and then launching the script change them all together. Then a random check - and configs can be poured back into the machines.

Distribute changed pacs.xml files to clients


The simplest thing that came to mind was to make changes to the already working .bat file that collects configurations from clients and add a line:

 If exist %APPDATA%\RadiantViewer\pacs.xml copy /Y \\srv.test.local\pconfigsnew$\pacs-%COMPUTERNAME%-%USERNAME%.xml %APPDATA%\RadiantViewer\pacs.xml 

The resulting .bat file looks like this:

 @echo off If exist %APPDATA%\RadiantViewer\pacs.xml copy %APPDATA%\RadiantViewer\pacs.xml \\srv.test.local\pconfigs$\pacs-%COMPUTERNAME%-%USERNAME%.xml If exist %APPDATA%\RadiantViewer\pacs.xml copy /Y \\srv.test.local\pconfigsnew$\pacs-%COMPUTERNAME%-%USERNAME%.xml %APPDATA%\RadiantViewer\pacs.xml 

Conclusion


Such a “ knee-length ” solution. We tried it twice already (in September 2018 and in February 2019), while the flight is normal. Of course, not 100% of clients update, but close to this value - the rest is completed remotely. Script on the link .

Source: https://habr.com/ru/post/448270/


All Articles