Mercurial > hg > orthanc
changeset 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 | af8628ea91b3 |
children | 82567bac5e25 |
files | NEWS OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Resources/Samples/WebApplications/DrawingDicomizer/index.html Resources/Samples/WebApplications/DrawingDicomizer/orthanc.js Resources/Samples/WebApplications/NodeToolbox.js |
diffstat | 5 files changed, 79 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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 <glog/logging.h> @@ -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<ChangeType_ModifiedStudy, ResourceType_Study>); Register("/patients/{id}/anonymize", AnonymizeResource<ChangeType_ModifiedPatient, ResourceType_Patient>); - Register("/tools/create-dicom", Create); + Register("/tools/create-dicom", CreateDicom); } }
--- 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 @@ <body> <canvas id="canvas" width="490" height="220"></canvas> <p> - Patient Name: <input type="text" id="patientName"></input> + Patient ID: <input type="text" id="patientID"></input> + </p> + <p> + Patient Name: <input type="text" id="patientName" value="HELLO^WORLD"></input> + </p> + <p> + Study Description: <input type="text" id="studyDescription" value="My Study"></input> + </p> + <p> + Series Description: <input type="text" id="seriesDescription" value="My Series"></input> </p> <p> <button id="submit">Submit</button>
--- 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; });
--- 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);