# HG changeset patch # User Sebastien Jodogne # Date 1409755766 -7200 # Node ID 009dce4ea2f65e09aa9f51a1662d61a4e7baa164 # Parent af8628ea91b38722182e8e8c4dec334f2d87f749 /tools/create-dicom now accepts PatientID diff -r af8628ea91b3 -r 009dce4ea2f6 NEWS --- a/NEWS Wed Sep 03 14:08:15 2014 +0200 +++ b/NEWS Wed Sep 03 16:49:26 2014 +0200 @@ -2,9 +2,10 @@ =============================== * Refactoring of HttpOutput ("Content-Length" header is now always sent) +* "/tools/create-dicom" now accepts the "PatientID" DICOM tag (+ updated sample) * Fixes for Visual Studio 2013 and Windows 64bit +* Upgrade to Mongoose 3.8 * Experimental "KeepAlive" configuration option to enable HTTP Keep-Alive -* Upgrade to Mongoose 3.8 Version 0.8.2 (2014/08/07) diff -r af8628ea91b3 -r 009dce4ea2f6 OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Wed Sep 03 14:08:15 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Wed Sep 03 16:49:26 2014 +0200 @@ -34,6 +34,7 @@ #include "OrthancRestApi.h" #include "../FromDcmtkBridge.h" +#include "../../Core/Uuid.h" #include @@ -424,7 +425,7 @@ } - static void Create(RestApiPostCall& call) + static void CreateDicom(RestApiPostCall& call) { // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}' // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World","PixelData":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="}' @@ -433,8 +434,15 @@ if (call.ParseJsonRequest(request) && request.isObject()) { DicomModification modification; + modification.SetLevel(ResourceType_Patient); ParseReplacements(modification, request); + // If no PatientID is specified, create a random one + if (!modification.IsReplaced(DICOM_TAG_PATIENT_ID)) + { + modification.Replace(DICOM_TAG_PATIENT_ID, Toolbox::GenerateUuid()); + } + ParsedDicomFile dicom; if (modification.IsReplaced(DICOM_TAG_PIXEL_DATA)) @@ -474,6 +482,6 @@ Register("/studies/{id}/anonymize", AnonymizeResource); Register("/patients/{id}/anonymize", AnonymizeResource); - Register("/tools/create-dicom", Create); + Register("/tools/create-dicom", CreateDicom); } } diff -r af8628ea91b3 -r 009dce4ea2f6 Resources/Samples/WebApplications/DrawingDicomizer/index.html --- a/Resources/Samples/WebApplications/DrawingDicomizer/index.html Wed Sep 03 14:08:15 2014 +0200 +++ b/Resources/Samples/WebApplications/DrawingDicomizer/index.html Wed Sep 03 16:49:26 2014 +0200 @@ -15,7 +15,16 @@

- Patient Name: + Patient ID: +

+

+ Patient Name: +

+

+ Study Description: +

+

+ Series Description:

diff -r af8628ea91b3 -r 009dce4ea2f6 Resources/Samples/WebApplications/DrawingDicomizer/orthanc.js --- 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; }); diff -r af8628ea91b3 -r 009dce4ea2f6 Resources/Samples/WebApplications/NodeToolbox.js --- a/Resources/Samples/WebApplications/NodeToolbox.js Wed Sep 03 14:08:15 2014 +0200 +++ b/Resources/Samples/WebApplications/NodeToolbox.js Wed Sep 03 16:49:26 2014 +0200 @@ -35,15 +35,24 @@ opts.method = 'GET'; http.get(opts, function(response) { - response.setEncoding('utf-8'); - response.on('data', function(chunk) { - res.write(chunk); - }); - response.on('end', function() { + if (response.statusCode == 200) { + response.setEncoding('utf-8'); + response.on('data', function(chunk) { + res.write(chunk); + }); + response.on('end', function() { + res.end(); + }); + } else { + console.log('Got error on GET forwarding: ' + + response.statusCode + ' (' + path + ')'); + res.writeHead(response.statusCode); res.end(); - }); + } }).on('error', function(e) { - console.log('Got error on GET forwarding: ' + e.message + ' (' + path + ')'); + console.log('Unable to contact Orthanc: ' + e.message); + res.writeHead(503); // Service Unavailable + res.end(); }); } @@ -57,15 +66,24 @@ } var req = http.request(opts, function(response) { - response.setEncoding('utf-8'); - response.on('data', function(chunk) { - res.write(chunk); - }); - response.on('end', function() { + if (response.statusCode == 200) { + response.setEncoding('utf-8'); + response.on('data', function(chunk) { + res.write(chunk); + }); + response.on('end', function() { + res.end(); + }); + } else { + console.log('Got error on POST forwarding: ' + + response.statusCode + ' (' + path + ')'); + res.writeHead(response.statusCode); res.end(); - }); + } }).on('error', function(e) { - console.log('Got error on POST forwarding: ' + e.message + ' (' + path + ')'); + console.log('Unable to contact Orthanc: ' + e.message); + res.writeHead(503); // Service Unavailable + res.end(); }); req.write(body);