changeset 1702:bc40b6450261

"patient" GET argument
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Nov 2020 13:57:28 +0100
parents b5a8bf32d969
children 76c590a62755
files Applications/StoneWebViewer/NOTES.txt Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 3 files changed, 101 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/NOTES.txt	Fri Nov 27 12:21:26 2020 +0100
+++ b/Applications/StoneWebViewer/NOTES.txt	Fri Nov 27 13:57:28 2020 +0100
@@ -5,6 +5,7 @@
 
 - The images are retrieved using DICOMweb.
 
+
 - The Stone Web viewer uses the DICOM identifiers. The Osimis Web
   viewer the Orthanc identifiers.
   https://book.orthanc-server.com/faq/orthanc-ids.html
@@ -20,21 +21,40 @@
   To open a single series:
   http://.../index.html?study=<StudyInstanceUID>&series=<SeriesInstanceUID>
 
+
+- In the Osimis Web viewer, the "OpenAllPatientStudies" configuration
+  option can be provided to search Orthanc for all studies from
+  patients with the same PatientID as the selected study, then display
+  them.
+
+  In the Stone Web viewer, the "OpenAllPatientStudies" configuration
+  option is replaced by the single "patient" GET argument. This option
+  contains a comma-separated list of "Patient ID" tag (0010,0020).
+
+  To open all the studies of one patient:
+  http://.../index.html?patient=<PatientID>
+
+  To open all the studies of several patients:
+  http://.../index.html?patient=<PatientID1>,<PatientID2>,...
+
+
 - In the Osimis Web viewer, the "pickableStudyIds" parameter in the
   URL defines the list of studies that are available for display, and
   that are listed in the dropdown at the top-left of the interface.
 
   In the Stone Web viewer, "pickableStudyIds" is replaced by the
   single "study" GET argument, that is allowed to contain a
-  comma-separated list of studies. The "series" parameter is ignored
-  in this case.
+  comma-separated list of studies. The "series" parameter must not be
+  provided in this case.
 
   To open a list of studies:
   http://.../index.html?study=<StudyInstanceUID1>,<StudyInstanceUID2>,...
-  
-- In the Osimis Web viewer, the "selectedStudyIds" defines the list of
-  studies that are selected in the dropdown (and therefore displayed
-  when the viewer starts).
+
+
+- In the Osimis Web viewer, the "selectedStudyIds" parameter in the
+  URL defines the list of studies that are selected in the dropdown at
+  the top-left corner of the viewer (those studies are therefore
+  displayed when the viewer starts).
 
   In the Stone Web viewer, "selectedStudyIds" is replaced by the
   "selectedStudies" GET argument, that is allowed to contain a
--- a/Applications/StoneWebViewer/WebApplication/app.js	Fri Nov 27 12:21:26 2020 +0100
+++ b/Applications/StoneWebViewer/WebApplication/app.js	Fri Nov 27 13:57:28 2020 +0100
@@ -842,6 +842,7 @@
   app.SetCombinedToolActions();
   
   var selectedStudies = getParameterFromUrl('selectedStudies');
+  var patient = getParameterFromUrl('patient');
   var study = getParameterFromUrl('study');
   var series = getParameterFromUrl('series');
 
@@ -850,23 +851,40 @@
   } else {
     app.selectedStudies = [];
   }
-  
-  if (study === undefined) {
-    alert('No study was provided in the URL!');
-  } else {
-    var studies = study.split(',');
-    if (studies.length > 1) {
-      for (var i = 0; i < studies.length; i++) {
-        console.warn('Loading study: ' + studies[i]);
-        stone.FetchStudy(studies[i]);
+
+  if (study !== undefined &&
+      series !== undefined) {
+    console.warn('Loading series: ' + series + ' from study: ' + study);
+    stone.FetchSeries(study, series);
+    app.leftMode = 'full';
+  }
+  else {
+    var empty = true;
+
+    if (study !== undefined) {
+      var studies = study.split(',');
+      if (studies.length != 0) {
+        empty = false;
+        for (var i = 0; i < studies.length; i++) {
+          console.warn('Loading study: ' + studies[i]);
+          stone.FetchStudy(studies[i]);
+        }
       }
-    } else if (series === undefined) {
-      console.warn('Loading study: ' + study);
-      stone.FetchStudy(study);
-    } else {
-      console.warn('Loading series: ' + series + ' from study: ' + study);
-      stone.FetchSeries(study, series);
-      app.leftMode = 'full';
+    }
+
+    if (patient !== undefined) {
+      var patients = patient.split(',');
+      if (patients.length != 0) {
+        empty = false;
+        for (var i = 0; i < patients.length; i++) {
+          console.warn('Loading patient: ' + patients[i]);
+          stone.FetchPatient(patients[i]);
+        }
+      }
+    }
+
+    if (empty) {
+      alert('No study, nor patient was provided in the URL!');
     }
   }
 });
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Nov 27 12:21:26 2020 +0100
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Nov 27 13:57:28 2020 +0100
@@ -277,12 +277,22 @@
     }
   }
 
-  void FetchInternal(const std::string& studyInstanceUid,
+  void FetchInternal(const std::string& patientId,
+                     const std::string& studyInstanceUid,
                      const std::string& seriesInstanceUid)
   {
     // Firstly, load the study
     Orthanc::DicomMap filter;
-    filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false);
+
+    if (!patientId.empty())
+    {
+      filter.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, patientId, false);
+    }
+
+    if (!studyInstanceUid.empty())
+    {
+      filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false);
+    }
 
     std::set<Orthanc::DicomTag> tags;
     tags.insert(Orthanc::DICOM_TAG_STUDY_DESCRIPTION);  // Necessary for Orthanc DICOMweb plugin
@@ -305,7 +315,7 @@
 
     pending_ += 2;
   }
-
+  
 
   class PdfInfo : public Orthanc::IDynamicObject
   {
@@ -378,18 +388,33 @@
   
   void FetchAllStudies()
   {
-    FetchInternal("", "");
+    FetchInternal("", "", "");
+  }
+  
+  void FetchPatient(const std::string& patientId)
+  {
+    if (!patientId.empty())
+    {
+      FetchInternal(patientId, "", "");
+    }
   }
   
   void FetchStudy(const std::string& studyInstanceUid)
   {
-    FetchInternal(studyInstanceUid, "");
+    if (!studyInstanceUid.empty())
+    {
+      FetchInternal("", studyInstanceUid, "");
+    }
   }
   
   void FetchSeries(const std::string& studyInstanceUid,
                    const std::string& seriesInstanceUid)
   {
-    FetchInternal(studyInstanceUid, seriesInstanceUid);
+    if (!studyInstanceUid.empty() &&
+        !seriesInstanceUid.empty())
+    {
+      FetchInternal("", studyInstanceUid, seriesInstanceUid);
+    }
   }
 
   size_t GetStudiesCount() const
@@ -2775,6 +2800,16 @@
   }
 
   EMSCRIPTEN_KEEPALIVE
+  void FetchPatient(const char* patientId)
+  {
+    try
+    {
+      GetResourcesLoader().FetchPatient(patientId);
+    }
+    EXTERN_CATCH_EXCEPTIONS;
+  }
+
+  EMSCRIPTEN_KEEPALIVE
   void FetchStudy(const char* studyInstanceUid)
   {
     try