changeset 342:a58a8be26aff

generation of random uid in the rest api
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 18 Jan 2013 10:17:11 +0100
parents b51c67f28b33
children b1edbd636cb8
files OrthancServer/OrthancRestApi.cpp
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi.cpp	Thu Jan 17 16:01:58 2013 +0100
+++ b/OrthancServer/OrthancRestApi.cpp	Fri Jan 18 10:17:11 2013 +0100
@@ -317,6 +317,27 @@
     call.GetOutput().AnswerJson(result);
   }
 
+  static void GenerateUid(RestApi::GetCall& call)
+  {
+    std::string level = call.GetArgument("level", "");
+    if (level == "patient")
+    {
+      call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Patient), "text/plain");
+    }
+    else if (level == "study")
+    {
+      call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study), "text/plain");
+    }
+    else if (level == "series")
+    {
+      call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series), "text/plain");
+    }
+    else if (level == "instance")
+    {
+      call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Instance), "text/plain");
+    }
+  }
+
 
   // List all the patients, studies, series or instances ----------------------
  
@@ -1441,5 +1462,7 @@
     Register("/instances/{id}/anonymize", AnonymizeInstance);
     Register("/series/{id}/anonymize", AnonymizeSeriesInplace);
     Register("/studies/{id}/anonymize", AnonymizeStudyInplace);
+
+    Register("/tools/generate-uid", GenerateUid);
   }
 }