10/20/2020
I am kicking this pile of crap back to alpha. I just thought this was in beta. Boy I was wrong. I just found 2 issues with my code and EVEN WORSE SOMETHING HORRIBLE ABOUT ORTHANC.
1) minor issue: I need to check the logs and add more entries in the proxy settings in apache /etc/apache2/sites-available/000-default.conf. So in the Apache interface the Query to another dicom server does not work. This is the kind of issue I was expecting. Like oops. 5 minutes fix.
2) MAJOR ISSUE: This is basically an Orthanc REST quirk. I was not expecting this at all. I guess I should have been. But sending a patient with pdfs added by the interface to another server like EFILM; it does not transfer the pdfs. (beats head angainst wall) I will test further to see if transfers between copies of Orthanc to see if it transfers correctly or not. I may try a transfer to a PACS1 server. This would have to be resolved. This is really bad. I hang my head in shame. Puts gun in mouth...
HOWEVER IF POSSIBLE THIS IS EVEN MORE HORRIBLE:
3) I just realized that ORTHANC does not have a SEND QUEUE. Holy crapinolly. I am not sure I am going to bother to even work on this project now. Without a send queue to be able to fire off 4 or 5 studies at once to 2 or 3 servers, what is the point? This is a horrible realization. I could not even consider trying to make a tech use Orthanc now. Oh yeah... forget suicide... the tech would kill me with a hammer.
I suppose some kind of queue could be devised. It depends on whether the Orthanc engine will do multiple transfers at once. A page would have to be written to display progress bars.... ugggggckkkkkkk. I will have to get really drunk to get brave enough to even try to do this.
Orthanc apparently should only be used on local networks., it would seem. I will test this further but with any transfers going out of the local network over a slow internet tunnel the operator has to wait until the transfer finishes before starting another. Some kind of queue has to be created. There doesn't even appear to be a progress bar. OMFG. I can't believe I didn't check that out.
After noticing this I have a hard time thinking that Orthanc is used in all the places they have listed in the description. Really? With no send queue? And no progess bars on outgoing transfers?
Oh well deep sigh. If you never hear from me again it's because I jumped off a cliff in despair. We don't have any cliffs in FLorida so I am just joking.
10/16/2020
The following project is a paper scanning portal that gives the Orthanc Pacs server the ability to interface with twain/wia scanners and insert the resulting pdf into the Orthanc database using a web interface integrated into the Orthanc web console.
The nature of this project and its complexity suggests it includes a VMware virtual machine with a working copy of Orthanc and the paper scanning interface loaded within it. In addition,there are shortcut instructions for creating your own working copies of Orthanc by compiling Orthanc from scratch. These instructions include minimal settings for Orthanc and the installation of the scanner portal code and its required environment and even compilation of its executables.
Because of the Virtual Machine this package contains, it might also be used as a starter expo kit for Orthanc. I would have gone straight to this a month ago. Just remember there are 2 web interfaces in the downloadable VM. The normal Orthanc console on port 8042 and the one for the modified Orthanc console on port 80 with the scanning code injected into it.
The vast majority of the paper scanning side of project is written in server side PHP and interfaces using tcp port 8888 with an Autoit compiled executable which can be installed into a Windows 10 or 7 workstation. The interface has a Windows installer built into it that will show up as a green link if it does not see the scanner_listener.exe port respond to a focus command. This is an open source project so the installer is unsigned. You will get the irritating accusatory Microsoft blue screen whine. Just click "more information" at the top and download it. Read the pdf within the package.
The portal package code is within orthanc_scanner_portal.tgz which will be on SourceForge. To open it in Windows use winrar, winzip or anything that will read a tar ball. It also includes the source code for the two Windows executables. To use the package you do not have to roll your own executables, but given how easy it is to do I am suggesting you do compile your own code. If you are a tad lazy like we all are occasionally or you use a virtual pc to test unknown packages as we all should, there is nothing evil in the compiled executables.
Orthanc is written with its own web server daemon with an integrated REST interface engine server side and JavaScript client side; quite a feat by the author. We must assume the format is intended to emulate internet sites such as Facebook, Twitter, Instagram and Google Maps. All communication between the JavaScript web client and server is json text data streams. The dicom viewer’s data streams might be a separate discussion.
To implement the use of a paper scanner on a web page requires the web page to communicate directly with the client side and by some miracle instigate the paper scanner through its driver and initiating code into doing something useful. It then must ready itself to receive back through this series string of Christmas tree light bulbs the resulting image data and upon an appropriate completion point, submit said data for further processing.
I considered briefly doing this project in JavaScript client side like Orthanc does and obviously this can still be done, and is kind of a future goal, but because of the security restriction imposed by the industry on JavaScript for whatever insane reason disguised as security, raw tcp ports cannot be easily used; only secured websocket ports are allowed. The added websocket complexity puts an open source project like this one immediately in the dirt without at least some compromises, and compromises they were made.
To get something working, I introduced server side PHP to communicate with the Windows client because it most definitely supports simple raw tcp ports which can be easily used with Autoit and offers up all the tools available in the server side Linux environment like Ghostscript. Autoit on the client side gives some window focus functions which I put to use so that windows don't get lost behind web pages.
I decided trying to invent websockets in Autoit was more than I wanted to tackle. Note it does look like it might be possible to support websockets in Autoit, but if we go that far the communication daemon should be redone in CPP if JavaScript is to be used. Eventually using something like NAPS2 for the twain/wia that actually has the source code available, this project might shape up into something nice. At the moment my efforts are more of an amusing bag of tricks slung together, although maybe an interesting one, not because it bypasses the Orthanc author's intent of doing maximum client side, but because I managed to make it work at all. But let's be honest, some of these web scanning software packages cost $20k USD. I must assume this project has at least some value solely based on what they charge for such web scanning software packages, even if you bump into a quirk.
But now you must be wondering how did I interface PHP within Apache2 to a Rest interface and integrate any web page code into the existing compiled Orthanc web interface? You are asking that right? Amazingly that turned out to be rather easy. Apache2 has quite a few tricks up its sleeve if one is curious enough to scratch around in the dark corners of the internet. It allows the use of something it calls ProxyPass and ProxyPassReverse. Dump the html and JavaScript files out of the Orthanc tar ball into /var/www/html, tweak /etc/apache2/sites-available/000-default.conf in Linux and you suddenly have a stable copy of the Orthanc web console running in Apache2. It signs in using Orthanc's credentials and suddenly there are a whole plethora of possibilities. In fact this appears to be a perfect way to make modifications of any nature to the Orthanc interface. It's so stable the Orthanc interface can be run that way permanently at least until the author codes such possibilities out of existence. Maybe he will be kind of enough not to do that for a while.
The next step was to find a paper scanning executable that could create pdfs and that wouldn't be too irritating. Orthanc's REST interface will take pdf files if converted to json text. I chose CmdTwain from an obscure character out of Australia who apparently spends all day in the Outback roping kangaroos. He never answers any emails. His code seems to work well enough. Impressively it will save a pdf to a UNC path, bravo. But his documentation for the command line parameters are spread out in 4 or 5 disassociated places. So far the only real quirk to be found in his code is that his black and white settings produce a pdf that is at least 16 times larger than it should be. On a single page it is 2.5M for something that should be 150K. Digging around I found some Ghostscript commands to call that drastically downsize the pdf. Note the PHP code will run with or without the Ghostscript installed. But because I feel it's wrong to let people scan in b&w thinking they are saving space and that not be the case, I took a stab at reducing them. I drastically downsize any b&w scans by lowering the dpi to trigger whatever magic Ghostscript is doing. 2.5M per page becomes more like 75k and a bit more acceptable.
UPDATE: I have started looking at https://www.naps2.com/doc-command-line.html. It's open source and does about the same thing. However it does not seem to have a nice little popup window that CmeTwain has that lets the user chose the twain/wia device. That is a nice feature by the author. I am not sure yet what Naps2 does. Profiles for every scanner? In other respects Naps2 looks to be more comprehensive. OCR seems an interesting concept; not sure anyone would use OCR on a Pacs server. Bet their b&ws are not as bloated. But Ghostscript takes care of that quite well. The extra time on 25 scanned pages is barely noticable.
As a side note I have found that neither CmdTwain nor Naps2 will correctly use my network Brother MFC-L2710DW sheet feeder. The Brother scanner interface has to be used to get it to act right. Hopefully that is not a scanner that will be needed much. Fairly sure any version of any web interface will have the same issue with that scanner. I need more scanner hardware to do more testing.
You might also realize that the Apache2 web server holding its own copy of the Orthanc web interface doesn’t have to be on the Orthanc server, although that is a quite reasonable location for it. As long as it’s on the local network, the web server could run on any Linux virtual machine in Esxi, VMware Workstation, Hyper-V, Oracle VirtualBox which is free, or even some junk pc that is too small for Windows. As long as the pc has 2 gigs of ram and a hard drive that is still viable a paper scanning portal can be created. 6.5 Esxi will run on 4 gigs of ram as long as the CPU supports VT.
YOU HAVE TWO CHOICES
1) PREMADE VIRTUAL MACHINE: Download the VM image OVA (root 12345) ready to be installed and run, complete with a copy of Orthanc and a test image.
2) ROLL YOUR OWN FROM SCRATCH: Download the .tgz portal package and hack your way through the jungle of instructions to create your own Debian install from scratch. If you are just going to create a portal and point at a copy of Orthanc, it's not too bad. If you intend to also compile your own Orthanc from scratch you better bring snacks to eat while you watch stuff on the screen. Note: No reason it will not run in Centos or other flavors. But let's not get crazy here. Keep it simple. Graphical desktops accomplish nothing. Don't run this in Unbuntu with 500 Megs of ram just because that's the only version you love.
USING OVA IMAGE to CREATE SCANNER PORTAL
Using the VM OVA image will be the quickest and easiest way to getting something operational to play with. I gave you an exported OVA out of an ESXi 6.5 server (root 12345) which can be imported obviously into another ESXi 6 or later server. I always use version 11 vsphere 6.0, because I hate VMware's new web interface. I tested it as an import in Windows 10 VMware workstation 15.5. It worked flawlessly. Just make sure it is using bridged network mode. Because if the VM winds up behind a NAT software router it will not work for all the blatantly obvious reasons. The OVA also works in Oracle VirtualBox with no issues. I am sure it could be imported into Hyper-V. There seems to be a command line conversion process to convert the vmdk into a VHD file which is really the only thing that is important.
The virtual is a ready to go test platform with the Orthanc database installed including a dicom x-ray test image of some scissors. The php paper scanning web page code is installed. As to make the vm ip portable /etc/apache2/sites-available/000-default.conf is written out of /etc/rc.local with the local IP injected. The viewer will work as soon as you start it, assuming your networking is set bridged and you have dhcp on your network. You don't even have to login to the vm. The ip will show on the login screen of the vm. See /etc/issue file. For any changes to the vm start with /etc/rc.local and /var/www/html/settings.php files.
All passwords in the virtual are 12345. This includes Orthanc: admin 12345, samba: orthanc_scanner 12345, and the virtual Linux os: root 12345. There is an orthanc user: orthanc 12345.
http://your-dhcp-ip will give you the Apache Orthanc page with scanner popup page once you are within a study. I made the link text blue in the Orthanc menu so it can be spotted. Unsurprisingly http://your-dhcp-ip:8042 gives you the raw Orthanc.
See also http://your-dhcp-ip/installs. You will find source code, some other stuff, and an install FAKE_SCANNER_twainds.win64.installer.2.1.3.msi which is a 64 bit fake scanner that dumps one image. It's useful for testing if you don't have a real scanner. If you're cautious enough to want to compile your own executables it is all there. http://your-vm-ip/installs has more stuff including all the source code for the windows scanner_listener.exe and package installer.
When you start the scanning popup window out of the Orthanc console, initially the PHP web page will obviously not be able to communicate with the scanner_listener.exe code. You will see a GREEN INSTALL LINK show up at the top. Clicking on the link allows downloading the install zip that will allow installation of scanner_listener.exe onto the workstation. Within the zip is an UNSIGNED install executable along with a pdf discussing my personal distaste for monetized signed installs. Extract it or run it. You can go past the ugly blue screen by clicking more information and run anyway.
Within the install folder I give the source code. There are 2 you will need to compile. The hardest part will be downloading and installing NSIS and AUTOIT. Autoit is used to create the communication with the web page and call CmdTwain. The source code for it is a single file. NSIS was used to create the install package. You will need the folder containing the files that get rolled up into it and the script file scanner_interface.nsi to make your own.
The virtual machine has the mods already made to the Orthanc web code and has the PHP code ready. It already has the Samba server installed and configured which is used to transfer the pdf file from the workstation to Linux portal. If you want, after testing, point it at your own Orthanc database see /var/www/html/settings.php. You have to set a user and password that is allowed to talk to your real Orthanc server. Also see /etc/rc.local to change the ip of the Orthanc installation that Apache2 will point to. It writes /etc/apache2/sites-available/000-default.conf on startup. There are 2 variables that can be used to point to the ip of the real Orthanc server. One ip is used to pull and push data to the Rest interface, the other points to the viewer. After changing where Apache2 points, you can stop and disable the Orthanc in the virtual. Use: systemctl stop orthanc and systemctl disable orthanc.
If you want to tweak the samba password change it in $orthanc_scanner_pass in same /var/www/html/settings.php file. You will also have to change it in the operating system to match. I have everything expecting 12345. I'd get it running first before messing with the passwords.
passwd orthanc_scanner
smbpasswd -a orthanc_scanner
I would also suggest you put a static ip in the vm and not let it float around dhcp, as it will be a web server of sorts. You can do that in /etc/network/interfaces in Debian flavors. Also don't forget to make sure /etc/resolv.conf has at least one nameserver ip entry for doing apt installs and updates. If your dhcp server is never rebooted and your network is really stable maybe you can leave it dhcp. It kind of depends on your router.
allow-hotplug ens192
iface ens192 inet static
address 192.168.x.y
netmask 255.255.255.0
gateway 192.168.x.z
nameserver 8.8.8.8
nameserver 8.8.4.4
Assuming you put it on a full sized ESXi server with some storage, you could theoretically add in your own storage drive into the virtual and immediately start using the virtual as your Orthanc installation. See your /etc/orthanc folder for settings. That is a Orthanc thing. See their docs. The storage in the vm points to /Storage in the root directory. Mount something larger there. Note the sqlite database has separate settings.
If you are using a Windows Orthanc server and the Linux scanner portal is aimed at the its ip, it should work. All the php code does is shove some base64 code in through the REST interface. The REST interface will either like it or reject it with an error message. I can't fathom how the Windows Orthanc REST interface could differ from the Linux flavor. But there is only so much I can do.
If you are considering running the PHP code directly in a Windows WAMP, unless you are really resourceful, don't bother. I think you could forget about Ghostscript or how I monitor for the open file as CmdTwain creates the pdf. Some other method would be needed. Just run the vm in Hyper-V, VMware Workstation or VirtualBox. I leave it to you to convert it. I have some plans to create a JavaScript version that will bypass the need for php server side. This will lend itself to you guys who do Windows. Whether I get it finished or not is anyone's guess. I have no idea if anyone will even use this.
WELCOME TO THE FUN AND ENTERTAINMENT SECTION
ROLLING YOUR OWN PORTAL FROM SCRATCH USING DEBIAN 10
Creating an installation for Linux from scratch is more involved. You better know your way around the vi editor or nano or something. Run this command:[ echo set nocompatible > /root/.vimrc ]. It makes vi tolerable. Any arrow keys while in edit mode makes it print characters otherwise. Download WinSCP that runs in Windows, it has a quite usable editor if you are command line challenged. WinSCP is useful for transferring files to and from. I wrote almost all the PHP code using it only because vi is irritating for some things. Forget doing search and replaces in it. If you don’t have it installed you’ll probably need it or something similar.
First thing you need is a Debian install, something along the lines of debian-10.5.0-amd64-netinst.iso. The version of 10.x doesn’t make much difference since the Debian net-install will roll itself up to the latest. You can use Centos if you know that better but you will have to extrapolate the instructions.
Creating a running copy of Linux is easiest in a virtual environment... obviously. You'll probably need to burn a cd if you are going the junk pc route. There is little need for the graphical desktop so I wouldn’t bother installing it so set “Debian desktop environment” off. The only software selections I leave is “Standard system utilities” and “SSH server”. I would set it up basically bare bones. I set the passwords all to 12345. You can do something more reasonable later after you get things running.
Login as root with whatever password you set in your install. First thing you want to try is pinging some site on the internet like google.com. You’re off to a bad start if you can’t and you better rethink what you're doing.
0) apt install network-manager (gives you nmtui which is useful for any network card changes.) Why this one is not standard is odd as you have to be on the internet to install it. So if your copy of Linux doesn’t connect to the network from the start you’re almost at a dead end. On the other side Centos doesn’t start an Ethernet interface for you but at least it comes with nmtui installed. Fun and games.
1) sudo is beyond idiotic unless you like useless challenges. vi /etc/ssh/sshd_config /Root [ PermitRootLogin yes ] so you can login in as root using putty.exe and copy and paste commands. Do [ systemctl restart sshd ] afterward or just reboot. Signed in with sudo su you can't even type reboot without supplying the path to the exe. I find it fascinating that tying the user's hands behind his back and calling it security is even tolerated. Maybe we should just blindfold the user as well and finish him off in front of a firing squad. That would secure him.
2) apt install net-tools (gives ifconfig)
3) apt install open-vm-tools (if you are in the VMware virtual enviro. Don’t bother if you are doing a bare metal.)
4) apt install apache2 php samba unzip (Let's actually start doing something useful)
5) Do php –v to figure out which version of php you wound up with.
6) apt install php7.3-curl (must match php version. Don't ask me why)
systemctl enable apache2
systemctl start apache2
This is an option. If you have a working Orthanc server you can just point to it. If you intend to make an Orthanc sever I would compile it since Debian tends to be behind in it repositories and from what I can tell you have to compile the OrthancGdcm package anyway. So you might as well just compile Orthanc too. They are both large but stupidly easy to do.
This guide was originally only meant to show you a way to create a paper scanning portal that can be pointed at a running copy of Orthanc. But I decided to include my notes for compiling Orthanc and OrthancGdcm because that is what is in the vm.
This is not to say that you cannot have your cake and eat it too. In Linux you can run Apache2 and Orthanc at the same time. In Linux you can run Apache2 and Orthanc at the same time within the same operating system... obviously. The virtual machine that I give you to download indeed has both installed and running complete with a sample database. Your playbox of toys awaits you. If you have no idea what you are doing yet or if you are just considering using Orthanc for the first time I would suggest you start there. If you don't have any idea what to do with a vm image and you wound up here you need to learn what that looks like. Virtualization is definitely a fascinating subject and surely not one to go away this century.
Compiling from scratch sounds daunting if you have never compiled something as complex as Orthanc in Linux or if you have ever wasted an entire day lost in some Linux compile nightmare. But in all reality I found compiling Orthanc easy. Note I am not saying it is a quick process. It takes a while for it to crunch.
Sign in with putty and copy paste these commands:
wget https://www.orthanc-server.com/downloads/get.php?path=/orthanc/Orthanc-1.7.4.tar.gz
mv 'get.php?path=%2Forthanc%2FOrthanc-1.7.4.tar.gz' Orthanc-1.7.4.tar.gz
tar zxvf Orthanc-1.7.4.tar.gz
see Orthanc-1.7.4/LinuxCompilation.txt
apt install build-essential unzip uuid-dev cmake
cd Orthanc-1.7.4
mkdir Build
cd Build
cmake -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Debug ../OrthancServer/
make
make install
chown root:root /etc/init.d/orthanc
chmod 755 /etc/init.d/orthanc
vi /etc/init.d/orthanc
add /usr/local/sbin/ to PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin/ (like this. Seemed logical)
Change DAEMON=/usr/sbin/Orthanc to DAEMON=/usr/local/sbin/Orthanc
systemctl enable orthanc
Important configuration files are found for Orthanc in the /etc/orthanc folder. The files all end in .json which looks horrible but they are just text files. There is no web interface YET that can be used to configure Orthanc. You have to do it by hand in those text files. Not rocket science.
And it appears as though the /etc/orthanc folder along with the files credentials.json & orthanc.json are not created in the compiled version. These have to be created by hand. I said it was easy to compile. I didn't say it was a cake walk. It's not that bad.
mkdir /etc/orthanc
cd /etc/orthanc
{
"RegisteredUsers" : {
"admin" : "12345"
}
}
Within the same /etc/orthanc folder if you don't have this file run this command in /etc/orthanc:
Orthanc --config=orthanc.json (spits out the default config which you will have to tweak)
It's cheating but you could copy the one out of the virtual if you grow weary of all of this.
cd /etc/orthanc
chmod +r *.json (make sure orthanc user has rights to read these files)
You could chown them as well.
You might need to control where you store data. Again pretty simple. I just move the database folder with cp -R to where I want it, guts, feathers and all. Make sure Orthanc is down when you do that one. In orthanc.json find these two lines and set them accordingly. One is the image data. One is the sqlite database location. I briefly considered using mysql but backed away from it. You have to compile it. It's another plugin. But with the REST interface why would we need raw access to the database? And sqlite is practically bomb proof unless you have a whole lot of data and big plans. A hospital would probably use mysql because of all the toys, replication and backup methods available.
Within /etc/orthanc/orthanc.json tweak to something like this to when you move storage. Index is the sqlite.
"StorageDirectory" : "/STORAGE/orthanc/db-v6",
"IndexDirectory" : "/STORAGE/orthanc/db-v6",
You going to need the following: A decent viewer for the images. ¡¡¡ALSO SEE COMPILING OrthancGdcm right below.!!!
"Plugins" : [
"/usr/local/share/orthanc/plugins/libOsimisWebViewer.so"
],
To use the Osimis Viewer you just download the precompiled from them and huck it into one of the plugin folders and path it in the plugins in orthanc.json. Again it's in the VM I give you.
That should get you up and running with the basics. To finish the project as a scanner portal keep going.
systemctl start orthanc
ps -e | grep Orthanc (Check if it is running)
cd /var/log/orthanc (Check the log. Found that a reboot of os might throw a log entry when starting & stopping doesn't.)
/usr/local/sbin/Orthanc
Running the Orthanc executable directly will not make it read /etc/orthanc/ json files but might give you a clue or some hope if something is wrong.
From what I can tell at the moment you are probably going to need OrthancGdcm. This was a revelation to me since I thought it was not necessary since using OsimisWebViewer. There seems to be no way to get it without compiling it and Orthanc doesn't seem to start without it. It appears that Orthanc will sporadically not start without this in the plugins. I assume it has something to do with what I have in my test database which was nothing odd that's for sure. I did have some real images at one point.
You are going to need "apt install build-essential unzip uuid-dev cmake" if you have not already installed them. No harm if you attempt them again.
wget https://www.orthanc-server.com/downloads/get.php?path=/plugin-gdcm/OrthancGdcm-1.1.tar.gz
mv 'get.php?path=%2Fplugin-gdcm%2FOrthancGdcm-1.1.tar.gz' OrthancGdcm-1.1.tar.gz
tar -zxvf OrthancGdcm-1.1.tar.gz
cd OrthancGdcm-1.1
mkdir Build
cd Build
cmake .. -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release
make
make install
Change plugins to this"
"Plugins" : [
"/usr/local/share/orthanc/plugins/libOrthancGdcm.so",
"/usr/local/share/orthanc/plugins/libOsimisWebViewer.so"
],
Create the file /root/.vimrc. Trust me if you use vi you'll thank me. You can use the arrow keys in edit mode again. Things get irritating otherwise with characters spewed all over the screen.
echo set nocompatible > /root/.vimrc
Now that you have Apache2, php, and phpcurl installed, download the orthanc_scanner_portal.tgz into /var/www/html and untar the package. The source code for all the code is in this one file. If you want to open it in windows to compile those sources use winrar.
cd /var/www/html
rm index.html
wget http://(path)/orthanc_scanner_portal.tgz
tar -zxvf orthanc_scanner_portal.tgz
I use rc.local which is not much supported in Debian. I find it useful anyway for all kinds of things. I use the folder /tmp/orthanc_scanner to create the file share location which gets eaten on a reboot. I like the idea of it cleaning itself on reboots. I also don’t quite trust Apache to auto load the modules. But if you see the world differently make any change you like. Just don't email me and call me names if it doesn't work.
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
systemctl enable rc-local
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_balancer
a2enmod lbmethod_byrequests
systemctl start apache2
mkdir /tmp/orthanc_scanner
chmod 777 /tmp/orthanc_scanner
systemctl start smbd
(Don't forget to do this)
chmod +x /etc/rc.local
(This is important)
To stop wacky names like :/tmp/systemd-private-eb7a2066fcd9465bb109b57830ed06d3-apache2.service-6XDa5g/
vi /usr/lib/systemd/system/apache2.service
comment out (with a #) the PrivateTmp parameter
systemctl daemon-reload or just wait for the reboot after you get it all configured
Set /etc/apache2/sites-available/000-default.conf to the following:
I do this in the rc.local in the virtual.
<virtualhost *:80="">
ServerAdmin webmaster@localhost
DirectoryIndex explorer.html
DocumentRoot /var/www/html</virtualhost>
# Here is one variable to set the ip to the Orthanc Rest interface
Define orthancip 192.168.x.x
# Optionally you could use 2 variables here if you installing directly on Orthanc database server
# Define orthancip 127.0.0.1
# Then for the viewer
# Define orthancipview 192.168.x.x
# However the viewer seems to run just fine Proxyed on reasonable hardware so either way works
# If you are trying to use a really slow pc with multiple clients a Redirect probably would be better
ProxyPass /plugins http://${orthancip}:8042/plugins
ProxyPassReverse /plugins http://${orthancip}:8042/plugins
ProxyPass /system http://${orthancip}:8042/system
ProxyPassReverse /system http://${orthancip}:8042/system
ProxyPass /studies http://${orthancip}:8042/studies
ProxyPassReverse /studies http://${orthancip}:8042/studies
ProxyPass /patients http://${orthancip}:8042/patients
ProxyPassReverse /patients http://${orthancip}:8042/patients
ProxyPass /series http://${orthancip}:8042/series
ProxyPassReverse /series http://${orthancip}:8042/series
ProxyPass /favicon.ico http://${orthancip}:8042/favicon.ico
# You should notice that it will ask for the password again if you redirect instead of Proxy
Redirect /osimis-viewer http://${orthancip}:8042/osimis-viewer
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
[global]
workgroup = WORKGROUP
log file = /var/log/samba/log.%m
max log size = 1000
logging = file
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = Enter\snew\s\spassword: %n\n Retype\snew\s\spassword: %n\n password\supdated\ssuccessfully .
pam password change = yes
map to guest = bad user
usershare allow guests = no
[orthanc_scanner]
path = /tmp/orthanc_scanner
available = yes
browsable = yes
public = yes
writable = yes
guest ok = no
read only = no
####force user = orthanc_scanner
You can set guest ok = yes if you don't want to deal with any security on the share. It's not like anything stays in there very long.
useradd orthanc_scanner
passwd orthanc_scanner
enter password twice 12345<<<
smbpasswd -a orthanc_scanner
enter password twice 12345<<<
If the password is set correctly in settings.php the php web page will be able to insert an entry into the Windows Credential Manager upon testing and failing to access the share. It will assume the failure is because of an authentication requirement and will try to insert an entry with the username orthanc_scanner. The password will be transmitted in plain text over your network. It should only do this once unless the Windows cannot remember the Credential entry. We have seen credential manager dementia on some W7 pcs. I think it's accidental ooops on purpose sabotage by Microsoft to cajole network admins to use 10.
Most pdfs are deleted after insertion. However if the operator scans some large stack of paper that takes more than 3 minutes which puts the interface into manual mode because of an approaching php time limit and then the operator doesn't upload the resulting pdf afterward then yes it will remain in the share until it is deleted by something, someone or the server is rebooted. A crontab entry could be created that cleans the folder nightly if you have concerns about sensitive material.
At this point reboot Linux.
WOO HOO TOYZ!
TESTING AND PLAYING WITH scanner_listener.exe ON LOCAL NETWORK
You can use putty.exe but you have to make sure it is in passive mode. Otherwise you get hieroglyphics.
Inside some Linux os like your Orthanc server:
telnet 192.168.x.w 8888 <-- Aimed at PC running scanner_listener.exe
Trying 192.168.x.w...
Connected to 192.168.x.w.
Escape character is '^]'.
status: <---- should respond status:alive. Utterly useless. lol
message:Are you there? <------shows up on taskbar in windoze. Might pop up after being opened. Good for irritating people.
The inclusion of a focus command here would be nice. I didn't do it as I grew weary of any more changes.
exeexists: <---------- asks if autoit can find the executable to the scanning software. Useful to know if something ate it.
selecttwain: <------- VERY USEFUL Gets called off page with a button. Hopefully the scanner operator will be smart enough to use it.
datetime: <--------- ask the time off workstation. Used to generate the file name. Doesn't really do much.
This checks if autoit running on workstation can see the share. Any share you ask about actually.
checkifshare:\192.168.x.s\orthanc_scanner <--question about Orthanc server
share:ready:\192.168.x.s\orthanc_scanner <--workstation sees share /tmp/orthanc WOOHOO!
checkifshare:\192.168.x.s\SOMETHINGWRONG <--bad question on purpose.
share:broken:\192.168.x.s\SOMETHINGWRONG <--broken!!! Notice how fast it can come back.
Initiate a scan and dump it into samba share on server. Obviously Orthanc will not process it yet. We're just testing here.
scanpaper:192.168.x.s: <---will default to ---> scanpaper:192.168.x.s:LETTER DPI 300 BW
fn=9-16-2020-3-02-12PM.pdf <---- responds with file name to be created or errors out with a complaint
Install certificate into credential manager in windows.
certmanage:orthancip:password
pid=4322 <---- responds with a pid
quit: <----- exit out of telnet.
Connection closed by foreign host.
Do you have to use quit:? No not really. It cleans up after itself.
In fact any connection whether left rudely running or live will drop on the 2nd connection.
MODIFICATIONS TO ORTHANC CODE (THIS HAS ALREADY BEEN DONE FOR YOU)
But if you feel compelled to peruse the changes. Here they are. This is close anyway. Popup window size might be different.
Modification of /var/www/html web pages running within Apache2. The following is the only two changes I have made so far to Orthanc code.
May I suggest using WinSCP. It has an editor that isn’t horrible. It's easier than using a vi editor. Although I can do vi in my sleep.
Change button:
$('#study-archive').live('click', function(e) {
e.preventDefault(); //stop the browser from following
window.location.href = '../studies/' + $.mobile.pageData.uuid + '/archive';
});
$('#study-pdf').live('click', function(e) {
e.preventDefault(); //stop the browser from following
var popupWindow = null;
h = 380; w = 600; <---increase for more stuff on screen to h = 380; w = 600;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
popupWindow = window.open('../uploadpdf.php' + '?study=' + $.mobile.pageData.uuid,'PDF UPLOAD',settings);
});
$('#series-archive').live('click', function(e) {
e.preventDefault(); //stop the browser from following
window.location.href = '../series/' + $.mobile.pageData.uuid + '/archive';
});
The wiki uses Markdown syntax.