changeset 4757:72a850947b11

In lookup and query/retrieve, possibility to provide a specific study date
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Jul 2021 08:14:05 +0200
parents 38374acc7435
children b1319a5304fb cb18a1869e4e
files NEWS OrthancServer/OrthancExplorer/explorer.html OrthancServer/OrthancExplorer/explorer.js OrthancServer/OrthancExplorer/query-retrieve.js
diffstat 4 files changed, 58 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Jul 19 15:13:40 2021 +0200
+++ b/NEWS	Tue Jul 20 08:14:05 2021 +0200
@@ -4,6 +4,7 @@
 Orthanc Explorer
 ----------------
 
+* In lookup and query/retrieve, possibility to provide a specific study date
 * Clicking on "Send to remote modality" displays the job information to monitor progress
 
 Maintenance
--- a/OrthancServer/OrthancExplorer/explorer.html	Mon Jul 19 15:13:40 2021 +0200
+++ b/OrthancServer/OrthancExplorer/explorer.html	Tue Jul 20 08:14:05 2021 +0200
@@ -87,6 +87,11 @@
           </select>
         </div>
 
+        <div data-role="fieldcontain">
+          <label for="lookup-study-date-specific"></label>
+          <input type="date" name="lookup-study-date-specific" id="lookup-study-date-specific" />
+        </div>
+
         <fieldset class="ui-grid-b">
           <div class="ui-block-a">
             <a href="#find-patients" data-role="button" data-theme="b" data-direction="reverse">All patients</a>
@@ -494,7 +499,7 @@
 
         <div data-role="fieldcontain">
           <label for="qr-value">Value for this field:</label>
-          <input type="text" name="qr-value" id="qr-value" value="*" />
+          <input type="text" name="qr-value" id="qr-value" value="" />
         </div>
 
         <div data-role="fieldcontain">
@@ -503,6 +508,11 @@
           </select>
         </div>
 
+        <div data-role="fieldcontain">
+          <label for="qr-date-specific"></label>
+          <input type="date" name="qr-date-specific" id="qr-date-specific" />
+        </div>
+
         <div data-role="fieldcontain" id="qr-modalities">
           <div data-role="fieldcontain">
             <fieldset data-role="controlgroup" data-type="horizontal">
--- a/OrthancServer/OrthancExplorer/explorer.js	Mon Jul 19 15:13:40 2021 +0200
+++ b/OrthancServer/OrthancExplorer/explorer.js	Tue Jul 20 08:14:05 2021 +0200
@@ -506,23 +506,39 @@
   target.append($('<option>').attr('value', GenerateDicomDate(-31) + '-').text('Last 31 days'));
   target.append($('<option>').attr('value', GenerateDicomDate(-31 * 3) + '-').text('Last 3 months'));
   target.append($('<option>').attr('value', GenerateDicomDate(-365) + '-').text('Last year'));
+  target.append($('<option>').attr('value', 'specific').text('Specific date'));
   target.selectmenu('refresh');
 
   $('#lookup-result').hide();
+  $('#lookup-study-date-specific').hide();
+});
+
+
+$('#lookup-study-date').live('change', function() {
+  if ($(this).val() == 'specific') {
+    $('#lookup-study-date-specific').show();
+  } else {
+    $('#lookup-study-date-specific').hide();
+  }
 });
 
 
 $('#lookup-submit').live('click', function() {
-  var lookup;
+  var lookup, studyDate;
 
   $('#lookup-result').hide();
 
+  studyDate = $('#lookup-study-date').val();
+  if (studyDate == 'specific') {
+    studyDate = IsoToDicomDate($('#lookup-study-date-specific').val());
+  }
+  
   lookup = {
     'Level' : 'Study',
     'Expand' : true,
     'Limit' : LIMIT_RESOURCES + 1,
     'Query' : {
-      'StudyDate' : $('#lookup-study-date').val()
+      'StudyDate' : studyDate
     },
     'Full' : true
   };
@@ -541,6 +557,9 @@
       else if (input.id == 'lookup-study-description') {
         lookup['Query']['StudyDescription'] = input.value;
       }
+      else if (input.id == 'lookup-study-date-specific') {
+        // Ignore
+      }
       else {
         console.error('Unknown lookup field: ' + input.id);
       }
--- a/OrthancServer/OrthancExplorer/query-retrieve.js	Mon Jul 19 15:13:40 2021 +0200
+++ b/OrthancServer/OrthancExplorer/query-retrieve.js	Tue Jul 20 08:14:05 2021 +0200
@@ -31,6 +31,11 @@
  **/
 
 
+function IsoToDicomDate(s)
+{
+  return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10);
+}
+
 function GenerateDicomDate(days)
 {
   var today = new Date();
@@ -48,8 +53,7 @@
   var timezoneOffset = today.getTimezoneOffset() * 60 * 1000;
   var localDate = new Date(utc.getTime() - timezoneOffset);
   
-  var s = localDate.toISOString();
-  return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10);
+  return IsoToDicomDate(localDate.toISOString());
 }
 
 
@@ -85,7 +89,19 @@
   targetDate.append($('<option>').attr('value', GenerateDicomDate(-31) + '-').text('Last 31 days'));
   targetDate.append($('<option>').attr('value', GenerateDicomDate(-31 * 3) + '-').text('Last 3 months'));
   targetDate.append($('<option>').attr('value', GenerateDicomDate(-365) + '-').text('Last year'));
+  targetDate.append($('<option>').attr('value', 'specific').text('Specific date'));
   targetDate.selectmenu('refresh');
+
+  $('#qr-date-specific').hide();
+});
+
+
+$('#qr-date').live('change', function() {
+  if ($(this).val() == 'specific') {
+    $('#qr-date-specific').show();
+  } else {
+    $('#qr-date-specific').hide();
+  }
 });
 
 
@@ -120,7 +136,12 @@
 
 
 $('#qr-submit').live('click', function() {
-  var query, server, modalities, field;
+  var query, server, modalities, field, studyDate;
+
+  studyDate = $('#qr-date').val();
+  if (studyDate == 'specific') {
+    studyDate = IsoToDicomDate($('#qr-date-specific').val());
+  }
 
   query = {
     'Level' : 'Study',
@@ -130,7 +151,7 @@
       'PatientID' : '',
       'PatientName' : '',
       'PatientSex' : '',
-      'StudyDate' : $('#qr-date').val(),
+      'StudyDate' : studyDate,
       'StudyDescription' : ''
     }
   };