Simple PHP Front-End with Web Viewer Launcher

Hi all,

I’ve been using (and getting my colleagues to use) Orthanc to present radiological images in our combined clinico-patho-radio conferences. Based on our experience, I’ve written a couple of simple scripts:

  • a simple PHP front-end, that allows searching (currently, of Patient Name, Patient ID, Study Date and Modality - including the use of wildcards, e.g. John*, 201505*, etc )
  • a web viewer launcher that accepts Patient ID, Patient UUID, Study Instance UID, Study UUID, Series Instance UID and Series UUID.

When loading a Study using the launcher, Orthanc’s built-in web viewer is seen in an IFRAME, with the links to all the series within the study shown on the screen. Likewise, when loading a Patient, the links to all the patient’s studies and series are also shown. This allows the user to quickly change between different series for the same patient / study.

Usage:

  • add the Orthanc instance into its own configuration.json as a modality using the name “local”, for example:

“DicomModalities” : {
“local” : [ “ORTHANC”, “localhost”, 4242 ]

},

  • edit config.php to change the $orthanc server variable

  • browse to search.php (supports both POST and GET)

Issues:

  • It takes a few seconds to load my small database of about 100 series (about 40 patients). I tried searching my Dose database of about 7000 patients, and the script completely failed. If anybody has any pointers on how I can go about fixing this problem (using PHP, without going into the innards of Orthanc) I’d appreciate it… :slight_smile:
  • There may be another way to perform modalities/{dicom}/find without declaring Orthanc as another server, but I can’t figure this out…

I’m 100% sure that there are a lot of bugs. Just sharing what I’m doing in my centre. Hope this helps whoever needs it. :slight_smile:

Regards,
Emsy

search.php (5.17 KB)

config.php (581 Bytes)

loadViewer.php (6.45 KB)

Hi,

Thanks again for this nice contribution!

I have just indexed this thread on GitHub:
https://github.com/jodogne/OrthancContributed/blob/master/Applications/Php/README.md

Sébastien-

Great effort, thanks for sharing.
But, What about using ajax instead of iframes
Its more efficient and flixable and can tolerate long loading time and backgroung loading

Thanks for your suggestion! :slight_smile:

At the moment, I’m running this within the LAN - which makes the load times quite tolerable for synchronous loading without AJAX. However, I agree that if I need to squeeze that extra bit of loading time, I will probably need to use AJAX. Also, Orthanc’s built-in web viewer performs caching, so you actually “pre-load” the series before starting the presentation to improve load-times when you are presenting. (Note: like I mentioned, this script was meant to help in presentations - not for clinical image review).

AJAX also runs into problems because of cross-domain issues - which needs additional configuration of the web server to overcome - something which I think might scare away some users. :slight_smile:

At the moment, I am trying to design a pure Javascript front-end for Orthanc (utilizing asynchronous loading) which make use of the ServeFolders plug-in, but I’m having trouble with long load times because of all the individual calls I need to make to Orthanc to retrieve all the necessary information.

Regards,
Emsy

Hi,

At the moment, I am trying to design a pure Javascript front-end for Orthanc (utilizing asynchronous loading) which make use of the ServeFolders plug-in, but I’m having trouble with long load times because of all the individual calls I need to make to Orthanc to retrieve all the necessary information.

Regarding this particular issue, the next release of Orthanc will provide a “?expand” flag that will avoid all these individual calls when querying the “/patients”, “/studies” and so on URIs.

Sébastien-

Thanks to Sébastien for letting me have access to the nightly build that supports ?expand!

I’ve updated my simple front-end to use only GET calls to retrieve information from Orthanc.

Now, there is no need to configure “local” DICOM modality in Configuration.json because I no longer need to use a POST call to modalities/local/find.

The only configuration needed now is to specify $orthanc in config.php. (Previous config.php and loadViewer.php files are unchanged).

The introduction of ?expand allows:

  • dropping the use of modalities/local/find (to search local databases)
  • pure GET commands so I hope I can port over to pure Javascript
  • better searching of large databases - BUT I still need about 40s to search a database of 6000 patients (“server” is a Xeon workstation with Orthanc running a PostGREs database) - the ?expand call needs about 10s each for patient, study and series in this large database.

Note: I developed and tested this on a mainline nightly build. Hoping that the 0.9.0 full release will improve performance. :slight_smile:

Regards,
Emsy

search.php (6.98 KB)

Hi Emsy,

Thanks for this feedback! Orthanc 0.9.0 should hopefully be released today.

I am very interested by the fact that you store 6000 patients with Orthanc. Can you tell me how many studies/series/instances this represent? You can get this information by downloading “http://localhost:8042/statistics”.

Also, when you write “I still need about 40s to search”, could you summarize what is the search you do and how you implement it? You must know that Orthanc 0.9.0 introduces the “http://localhost:8042/tools/find” URI that does the equivalent of a C-Find request, but using the REST API. This feature is not documented yet, but using it should drastically reduce the reported query time. Here is a sample query to find all the patients whose name contains “MA”:

curl http://localhost:8042/tools/find -X POST -d ‘{ “Expand” : true, “Level” : “Patient”, “CaseSensitive” : false, “Query” : { “PatientName” : “ma” } }’

This feature is already present in the nightly build I sent you two days ago.

Sébastien-


Hi Emsy,

Thanks for this feedback! Orthanc 0.9.0 should hopefully be released today.

I am very interested by the fact that you store 6000 patients with Orthanc. Can you tell me how many studies/series/instances this represent? You can get this information by downloading “http://localhost:8042/statistics”.

That is my CT dose database. It only stores 1 instance per 1 series per 1 study (i.e. the Patient Protocol).

{
   "CountInstances" : 7123,
   "CountPatients" : 5626,
   "CountSeries" : 7122,
   "CountStudies" : 7031,
   "TotalDiskSize" : "4237700768",
   "TotalDiskSizeMB" : 4041,
   "TotalUncompressedSize" : "4237700768",
   "TotalUncompressedSizeMB" : 4041
}
 

Also, when you write “I still need about 40s to search”, could you summarize what is the search you do and how you implement it?

To filter my 6000 patients:

About 40 seconds: (PHP call to Orthanc, both running on same server)

  • file_get_contents from /patient?expand
  • file_get_contents from /studies?expand
  • file_get_contents from /series?expand

Between 0 to 1 second: (in PHP)

  • if PatientName and PatientID are specified, cycle through patient array and trim array to those that match
  • if StudyDate is specified, cycle through study array and trim array to those that match
  • if Modality is specified, cycle through series array and trim array to those that match

Between 0 to 15 seconds: (in PHP)
Cycle through (trimmed) patients array, find matching study ID in (trimmed) study array
Cycle through matching series ID, find matching series ID in (trimmed) series array

You must know that Orthanc 0.9.0 introduces the “http://localhost:8042/tools/find” URI that does the equivalent of a C-Find request, but using the REST API. This feature is not documented yet, but using it should drastically reduce the reported query time. Here is a sample query to find all the patients whose name contains “MA”:

curl http://localhost:8042/tools/find -X POST -d ‘{ “Expand” : true, “Level” : “Patient”, “CaseSensitive” : false, “Query” : { “PatientName” : “ma” } }’

OK, I didn’t know about this new feature, but I just did some rough tests on it, and YES YES YES!!! In my 6000 patients:

  • It takes less than 5 seconds when I specify PatientName, StudyDate and Modality!
  • It takes about 10 seconds when I specify StudyDate and Modality!

Thank you so much!

Regards,
Emsy

Can you please give me the code on jsp to upload DICOM file in orthanc server?

jsp… Java Server Pages? Javascript? ASP?

not sure what you’re referring to…

can you please post an updated version of the application in which http://localhost:8042/tools/find is used ?

I’m only getting data in two of the five fields even though all show data when I run http://127.0.0.1:8042/studies?expand

Hello,

I think the response is returning all the fields…please see the screenshot

Untitled.png

Sorry, I meant when you're using tools/find (not studies?expand), which
was your actual question I think.

I've since checked and I was wrong, specifying the fields explicitly
doesn't have any effects on the response from tools/find (I think it's
a `modalities/{id}/query` thing instead).

It seems the only control you have is the Expand property. If you need
more metadata, you'll need to perform additional requests to retrieve
it.

Hello,

Please avoid discussing the same topic into two different threads.

The usage of “/tools/find” is not the topic of the present thread. Please discuss it here:
https://groups.google.com/d/msg/orthanc-users/hKIcotiOlnA/1bmLYhuMCgAJ

Sébastien-