changeset 4766:388d108f6e4b

Added "Level" option to POST /tools/bulk-modify
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Aug 2021 10:54:38 +0200
parents 71fbdee4b832
children e1711b6e141f
files NEWS OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp
diffstat 3 files changed, 41 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Aug 13 17:41:09 2021 +0200
+++ b/NEWS	Mon Aug 16 10:54:38 2021 +0200
@@ -1,6 +1,16 @@
 Pending changes in the mainline
 ===============================
 
+REST API
+--------
+
+* API version upgraded to 15
+* Added "Level" option to POST /tools/bulk-modify
+* Added missing OpenAPI documentation of "KeepSource" in ".../modify" and ".../anonymize"
+
+Maintenance
+-----------
+
 * Added file CITATION.cff
 * Linux Standard Base (LSB) builds of Orthanc can load non-LSB builds of plugins
 * Fix upload of ZIP archives containing a DICOMDIR file
--- a/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake	Fri Aug 13 17:41:09 2021 +0200
+++ b/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake	Mon Aug 16 10:54:38 2021 +0200
@@ -37,7 +37,7 @@
 # Version of the Orthanc API, can be retrieved from "/system" URI in
 # order to check whether new URI endpoints are available even if using
 # the mainline version of Orthanc
-set(ORTHANC_API_VERSION "14")
+set(ORTHANC_API_VERSION "15")
 
 
 #####################################################################
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Fri Aug 13 17:41:09 2021 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Mon Aug 16 10:54:38 2021 +0200
@@ -58,6 +58,7 @@
 static const char* const KEEP = "Keep";
 static const char* const KEEP_PRIVATE_TAGS = "KeepPrivateTags";
 static const char* const KEEP_SOURCE = "KeepSource";
+static const char* const LEVEL = "Level";
 static const char* const PARENT = "Parent";
 static const char* const PRIVATE_CREATOR = "PrivateCreator";
 static const char* const REMOVE = "Remove";
@@ -80,6 +81,15 @@
   }
 
 
+  static void DocumentKeepSource(RestApiPostCall& call)
+  {
+    call.GetDocumentation()
+      .SetRequestField(KEEP_SOURCE, RestApiCallDocumentation::Type_Boolean,
+                       "If set to `false`, instructs Orthanc to the remove original resources. "
+                       "By default, the original resources are kept in Orthanc.", false);
+  }
+
+
   static void DocumentModifyOptions(RestApiPostCall& call)
   {
     // Check out "DicomModification::ParseModifyRequest()"
@@ -102,6 +112,9 @@
                        "as this breaks the DICOM model of the real world.", false)
       .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String,
                        "The private creator to be used for private tags in `Replace`", false);
+
+    // This was existing, but undocumented in Orthanc <= 1.9.6
+    DocumentKeepSource(call);
   }
 
 
@@ -125,6 +138,9 @@
                        "List of DICOM tags whose value must not be destroyed by the anonymization. " INFO_SUBSEQUENCES, false)
       .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String,
                        "The private creator to be used for private tags in `Replace`", false);
+
+    // This was existing, but undocumented in Orthanc <= 1.9.6
+    DocumentKeepSource(call);
   }
 
 
@@ -443,6 +459,11 @@
         .SetSummary("Modify a set of resources")
         .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings,
                          "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true)
+        .SetRequestField(LEVEL, RestApiCallDocumentation::Type_String,
+                         "Level of the modification (`Patient`, `Study`, `Series` or `Instance`). If absent, "
+                         "the level defaults to `Instance`, but is set to `Patient` if `PatientID` is modified, "
+                         "to `Study` if `StudyInstanceUID` is modified, or to `Series` if `SeriesInstancesUID` "
+                         "is modified. (new in Orthanc 1.9.7)", false)
         .SetDescription("Start a job that will modify all the DICOM patients, studies, series or instances "
                         "whose identifiers are provided in the `Resources` field.")
         .AddAnswerType(MimeType_Json, "The list of all the resources that have been altered by this modification");
@@ -454,7 +475,15 @@
     Json::Value body;
     ParseModifyRequest(body, *modification, call);
 
-    modification->SetLevel(DetectModifyLevel(*modification));
+    if (body.isMember(LEVEL))
+    {
+      // This case was introduced in Orthanc 1.9.7
+      modification->SetLevel(StringToResourceType(body[LEVEL].asCString()));
+    }
+    else
+    {
+      modification->SetLevel(DetectModifyLevel(*modification));
+    }
 
     SubmitBulkJob(modification, false /* not an anonymization */, call, body);
   }