diff Resources/Samples/WebApplications/DrawingDicomizer/orthanc.js @ 1120:009dce4ea2f6

/tools/create-dicom now accepts PatientID
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Sep 2014 16:49:26 +0200
parents 557575fd93e9
children 6e7e5ed91c2d
line wrap: on
line diff
--- a/Resources/Samples/WebApplications/DrawingDicomizer/orthanc.js	Wed Sep 03 14:08:15 2014 +0200
+++ b/Resources/Samples/WebApplications/DrawingDicomizer/orthanc.js	Wed Sep 03 16:49:26 2014 +0200
@@ -24,23 +24,43 @@
  * SOFTWARE.
  **/
 
+function guid4Block() {
+  return Math.floor((1 + Math.random()) * 0x10000)
+    .toString(16)
+    .substring(1);
+}
+ 
+function guid() {
+  return (guid4Block() + guid4Block() + '-' + guid4Block() + '-' + guid4Block() + '-' +
+          guid4Block() + '-' + guid4Block() + guid4Block() + guid4Block());
+}
+
 
 $(document).ready(function() {
+  $('#patientID').val(guid());
+
   $('#submit').click(function(event) {
     var png = context.canvas.toDataURL();
 
     $.ajax({
       type: 'POST',
       url: '/orthanc/tools/create-dicom',
+      dataType: 'text',
       data: { 
+        PatientID: $('#patientID').val(),
         PatientName: $('#patientName').val(),
+        StudyDescription: $('#studyDescription').val(),
+        SeriesDescription: $('#seriesDescription').val(),
         PixelData: png,
-        Modality: 'RX' 
+        Modality: 'RX'
+      },
+      success : function(msg) {
+        alert('Your drawing has been DICOM-ized!\n\n' + msg);
+      },
+      error : function() {
+        alert('Error while DICOM-izing the drawing');
       }
-    })
-      .success(function( msg ) {
-        alert('Your drawing has been dicomized!\n\n' + msg);
-      });
+    });
 
     return false;
   });