changeset 1341:479e31b13de5

Allow replacing PatientID/StudyInstanceUID/SeriesInstanceUID from Lua scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 03 Apr 2015 13:53:08 +0200
parents 0ad4773f28b3
children 9ec7ac03152d
files NEWS OrthancServer/Scheduler/ModifyInstanceCommand.cpp OrthancServer/Scheduler/ModifyInstanceCommand.h OrthancServer/ServerContext.cpp
diffstat 4 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Apr 03 13:31:00 2015 +0200
+++ b/NEWS	Fri Apr 03 13:53:08 2015 +0200
@@ -3,6 +3,7 @@
 
 * Support of FreeBSD
 * Prevent freeze on C-FIND if no DICOM tag is to be returned
+* Allow replacing PatientID/StudyInstanceUID/SeriesInstanceUID from Lua scripts
 * Fix issue 30 (QR response missing "Query/Retrieve Level" (008,0052))
 
 
--- a/OrthancServer/Scheduler/ModifyInstanceCommand.cpp	Fri Apr 03 13:31:00 2015 +0200
+++ b/OrthancServer/Scheduler/ModifyInstanceCommand.cpp	Fri Apr 03 13:53:08 2015 +0200
@@ -36,6 +36,32 @@
 
 namespace Orthanc
 {
+  ModifyInstanceCommand::ModifyInstanceCommand(ServerContext& context,
+                                               const DicomModification& modification) :
+    context_(context),
+    modification_(modification)
+  {
+    modification_.SetAllowManualIdentifiers(true);
+
+    if (modification_.IsReplaced(DICOM_TAG_PATIENT_ID))
+    {
+      modification_.SetLevel(ResourceType_Patient);
+    }
+    else if (modification_.IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
+    {
+      modification_.SetLevel(ResourceType_Study);
+    }
+    else if (modification_.IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
+    {
+      modification_.SetLevel(ResourceType_Series);
+    }
+    else
+    {
+      modification_.SetLevel(ResourceType_Instance);
+    }
+  }
+
+
   bool ModifyInstanceCommand::Apply(ListOfStrings& outputs,
                                     const ListOfStrings& inputs)
   {
--- a/OrthancServer/Scheduler/ModifyInstanceCommand.h	Fri Apr 03 13:31:00 2015 +0200
+++ b/OrthancServer/Scheduler/ModifyInstanceCommand.h	Fri Apr 03 13:53:08 2015 +0200
@@ -45,15 +45,8 @@
     DicomModification modification_;
 
   public:
-    ModifyInstanceCommand(ServerContext& context) :
-      context_(context)
-    {
-    }
-
-    DicomModification& GetModification()
-    {
-      return modification_;
-    }
+    ModifyInstanceCommand(ServerContext& context,
+                          const DicomModification& modification);
 
     const DicomModification& GetModification() const
     {
--- a/OrthancServer/ServerContext.cpp	Fri Apr 03 13:31:00 2015 +0200
+++ b/OrthancServer/ServerContext.cpp	Fri Apr 03 13:53:08 2015 +0200
@@ -159,8 +159,10 @@
     if (operation == "modify")
     {
       LOG(INFO) << "Lua script to modify instance " << parameters["Instance"].asString();
-      std::auto_ptr<ModifyInstanceCommand> command(new ModifyInstanceCommand(context));
-      OrthancRestApi::ParseModifyRequest(command->GetModification(), parameters);
+      DicomModification modification;
+      OrthancRestApi::ParseModifyRequest(modification, parameters);
+
+      std::auto_ptr<ModifyInstanceCommand> command(new ModifyInstanceCommand(context, modification));
       return command.release();
     }