Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 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 | fb98db281d1d |
children | 61da49321754 94616af363ec |
comparison
equal
deleted
inserted
replaced
4765:71fbdee4b832 | 4766:388d108f6e4b |
---|---|
56 static const char* const INSTANCES = "Instances"; | 56 static const char* const INSTANCES = "Instances"; |
57 static const char* const INTERPRET_BINARY_TAGS = "InterpretBinaryTags"; | 57 static const char* const INTERPRET_BINARY_TAGS = "InterpretBinaryTags"; |
58 static const char* const KEEP = "Keep"; | 58 static const char* const KEEP = "Keep"; |
59 static const char* const KEEP_PRIVATE_TAGS = "KeepPrivateTags"; | 59 static const char* const KEEP_PRIVATE_TAGS = "KeepPrivateTags"; |
60 static const char* const KEEP_SOURCE = "KeepSource"; | 60 static const char* const KEEP_SOURCE = "KeepSource"; |
61 static const char* const LEVEL = "Level"; | |
61 static const char* const PARENT = "Parent"; | 62 static const char* const PARENT = "Parent"; |
62 static const char* const PRIVATE_CREATOR = "PrivateCreator"; | 63 static const char* const PRIVATE_CREATOR = "PrivateCreator"; |
63 static const char* const REMOVE = "Remove"; | 64 static const char* const REMOVE = "Remove"; |
64 static const char* const REPLACE = "Replace"; | 65 static const char* const REPLACE = "Replace"; |
65 static const char* const RESOURCES = "Resources"; | 66 static const char* const RESOURCES = "Resources"; |
75 | 76 |
76 static std::string GeneratePatientName(ServerContext& context) | 77 static std::string GeneratePatientName(ServerContext& context) |
77 { | 78 { |
78 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence, true /* shared */); | 79 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence, true /* shared */); |
79 return "Anonymized" + boost::lexical_cast<std::string>(seq); | 80 return "Anonymized" + boost::lexical_cast<std::string>(seq); |
81 } | |
82 | |
83 | |
84 static void DocumentKeepSource(RestApiPostCall& call) | |
85 { | |
86 call.GetDocumentation() | |
87 .SetRequestField(KEEP_SOURCE, RestApiCallDocumentation::Type_Boolean, | |
88 "If set to `false`, instructs Orthanc to the remove original resources. " | |
89 "By default, the original resources are kept in Orthanc.", false); | |
80 } | 90 } |
81 | 91 |
82 | 92 |
83 static void DocumentModifyOptions(RestApiPostCall& call) | 93 static void DocumentModifyOptions(RestApiPostCall& call) |
84 { | 94 { |
100 "Keep the original value of the specified tags, to be chosen among the `StudyInstanceUID`, " | 110 "Keep the original value of the specified tags, to be chosen among the `StudyInstanceUID`, " |
101 "`SeriesInstanceUID` and `SOPInstanceUID` tags. Avoid this feature as much as possible, " | 111 "`SeriesInstanceUID` and `SOPInstanceUID` tags. Avoid this feature as much as possible, " |
102 "as this breaks the DICOM model of the real world.", false) | 112 "as this breaks the DICOM model of the real world.", false) |
103 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, | 113 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, |
104 "The private creator to be used for private tags in `Replace`", false); | 114 "The private creator to be used for private tags in `Replace`", false); |
115 | |
116 // This was existing, but undocumented in Orthanc <= 1.9.6 | |
117 DocumentKeepSource(call); | |
105 } | 118 } |
106 | 119 |
107 | 120 |
108 static void DocumentAnonymizationOptions(RestApiPostCall& call) | 121 static void DocumentAnonymizationOptions(RestApiPostCall& call) |
109 { | 122 { |
123 "List of additional tags to be removed from the DICOM instances. " INFO_SUBSEQUENCES, false) | 136 "List of additional tags to be removed from the DICOM instances. " INFO_SUBSEQUENCES, false) |
124 .SetRequestField(KEEP, RestApiCallDocumentation::Type_JsonListOfStrings, | 137 .SetRequestField(KEEP, RestApiCallDocumentation::Type_JsonListOfStrings, |
125 "List of DICOM tags whose value must not be destroyed by the anonymization. " INFO_SUBSEQUENCES, false) | 138 "List of DICOM tags whose value must not be destroyed by the anonymization. " INFO_SUBSEQUENCES, false) |
126 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, | 139 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, |
127 "The private creator to be used for private tags in `Replace`", false); | 140 "The private creator to be used for private tags in `Replace`", false); |
141 | |
142 // This was existing, but undocumented in Orthanc <= 1.9.6 | |
143 DocumentKeepSource(call); | |
128 } | 144 } |
129 | 145 |
130 | 146 |
131 static void ParseModifyRequest(Json::Value& request, | 147 static void ParseModifyRequest(Json::Value& request, |
132 DicomModification& target, | 148 DicomModification& target, |
441 call.GetDocumentation() | 457 call.GetDocumentation() |
442 .SetTag("System") | 458 .SetTag("System") |
443 .SetSummary("Modify a set of resources") | 459 .SetSummary("Modify a set of resources") |
444 .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, | 460 .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, |
445 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) | 461 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) |
462 .SetRequestField(LEVEL, RestApiCallDocumentation::Type_String, | |
463 "Level of the modification (`Patient`, `Study`, `Series` or `Instance`). If absent, " | |
464 "the level defaults to `Instance`, but is set to `Patient` if `PatientID` is modified, " | |
465 "to `Study` if `StudyInstanceUID` is modified, or to `Series` if `SeriesInstancesUID` " | |
466 "is modified. (new in Orthanc 1.9.7)", false) | |
446 .SetDescription("Start a job that will modify all the DICOM patients, studies, series or instances " | 467 .SetDescription("Start a job that will modify all the DICOM patients, studies, series or instances " |
447 "whose identifiers are provided in the `Resources` field.") | 468 "whose identifiers are provided in the `Resources` field.") |
448 .AddAnswerType(MimeType_Json, "The list of all the resources that have been altered by this modification"); | 469 .AddAnswerType(MimeType_Json, "The list of all the resources that have been altered by this modification"); |
449 return; | 470 return; |
450 } | 471 } |
452 std::unique_ptr<DicomModification> modification(new DicomModification); | 473 std::unique_ptr<DicomModification> modification(new DicomModification); |
453 | 474 |
454 Json::Value body; | 475 Json::Value body; |
455 ParseModifyRequest(body, *modification, call); | 476 ParseModifyRequest(body, *modification, call); |
456 | 477 |
457 modification->SetLevel(DetectModifyLevel(*modification)); | 478 if (body.isMember(LEVEL)) |
479 { | |
480 // This case was introduced in Orthanc 1.9.7 | |
481 modification->SetLevel(StringToResourceType(body[LEVEL].asCString())); | |
482 } | |
483 else | |
484 { | |
485 modification->SetLevel(DetectModifyLevel(*modification)); | |
486 } | |
458 | 487 |
459 SubmitBulkJob(modification, false /* not an anonymization */, call, body); | 488 SubmitBulkJob(modification, false /* not an anonymization */, call, body); |
460 } | 489 } |
461 | 490 |
462 | 491 |