Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 4785:61da49321754 openssl-3.x
integration mainline->openssl-3.x
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Aug 2021 22:21:24 +0200 |
parents | 783f8a048035 388d108f6e4b |
children | 70d2a97ca8cb |
comparison
equal
deleted
inserted
replaced
4760:b2417ac5055a | 4785:61da49321754 |
---|---|
44 static const char* const INSTANCES = "Instances"; | 44 static const char* const INSTANCES = "Instances"; |
45 static const char* const INTERPRET_BINARY_TAGS = "InterpretBinaryTags"; | 45 static const char* const INTERPRET_BINARY_TAGS = "InterpretBinaryTags"; |
46 static const char* const KEEP = "Keep"; | 46 static const char* const KEEP = "Keep"; |
47 static const char* const KEEP_PRIVATE_TAGS = "KeepPrivateTags"; | 47 static const char* const KEEP_PRIVATE_TAGS = "KeepPrivateTags"; |
48 static const char* const KEEP_SOURCE = "KeepSource"; | 48 static const char* const KEEP_SOURCE = "KeepSource"; |
49 static const char* const LEVEL = "Level"; | |
49 static const char* const PARENT = "Parent"; | 50 static const char* const PARENT = "Parent"; |
50 static const char* const PRIVATE_CREATOR = "PrivateCreator"; | 51 static const char* const PRIVATE_CREATOR = "PrivateCreator"; |
51 static const char* const REMOVE = "Remove"; | 52 static const char* const REMOVE = "Remove"; |
52 static const char* const REPLACE = "Replace"; | 53 static const char* const REPLACE = "Replace"; |
53 static const char* const RESOURCES = "Resources"; | 54 static const char* const RESOURCES = "Resources"; |
63 | 64 |
64 static std::string GeneratePatientName(ServerContext& context) | 65 static std::string GeneratePatientName(ServerContext& context) |
65 { | 66 { |
66 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence, true /* shared */); | 67 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence, true /* shared */); |
67 return "Anonymized" + boost::lexical_cast<std::string>(seq); | 68 return "Anonymized" + boost::lexical_cast<std::string>(seq); |
69 } | |
70 | |
71 | |
72 static void DocumentKeepSource(RestApiPostCall& call) | |
73 { | |
74 call.GetDocumentation() | |
75 .SetRequestField(KEEP_SOURCE, RestApiCallDocumentation::Type_Boolean, | |
76 "If set to `false`, instructs Orthanc to the remove original resources. " | |
77 "By default, the original resources are kept in Orthanc.", false); | |
68 } | 78 } |
69 | 79 |
70 | 80 |
71 static void DocumentModifyOptions(RestApiPostCall& call) | 81 static void DocumentModifyOptions(RestApiPostCall& call) |
72 { | 82 { |
88 "Keep the original value of the specified tags, to be chosen among the `StudyInstanceUID`, " | 98 "Keep the original value of the specified tags, to be chosen among the `StudyInstanceUID`, " |
89 "`SeriesInstanceUID` and `SOPInstanceUID` tags. Avoid this feature as much as possible, " | 99 "`SeriesInstanceUID` and `SOPInstanceUID` tags. Avoid this feature as much as possible, " |
90 "as this breaks the DICOM model of the real world.", false) | 100 "as this breaks the DICOM model of the real world.", false) |
91 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, | 101 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, |
92 "The private creator to be used for private tags in `Replace`", false); | 102 "The private creator to be used for private tags in `Replace`", false); |
103 | |
104 // This was existing, but undocumented in Orthanc <= 1.9.6 | |
105 DocumentKeepSource(call); | |
93 } | 106 } |
94 | 107 |
95 | 108 |
96 static void DocumentAnonymizationOptions(RestApiPostCall& call) | 109 static void DocumentAnonymizationOptions(RestApiPostCall& call) |
97 { | 110 { |
111 "List of additional tags to be removed from the DICOM instances. " INFO_SUBSEQUENCES, false) | 124 "List of additional tags to be removed from the DICOM instances. " INFO_SUBSEQUENCES, false) |
112 .SetRequestField(KEEP, RestApiCallDocumentation::Type_JsonListOfStrings, | 125 .SetRequestField(KEEP, RestApiCallDocumentation::Type_JsonListOfStrings, |
113 "List of DICOM tags whose value must not be destroyed by the anonymization. " INFO_SUBSEQUENCES, false) | 126 "List of DICOM tags whose value must not be destroyed by the anonymization. " INFO_SUBSEQUENCES, false) |
114 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, | 127 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, |
115 "The private creator to be used for private tags in `Replace`", false); | 128 "The private creator to be used for private tags in `Replace`", false); |
129 | |
130 // This was existing, but undocumented in Orthanc <= 1.9.6 | |
131 DocumentKeepSource(call); | |
116 } | 132 } |
117 | 133 |
118 | 134 |
119 static void ParseModifyRequest(Json::Value& request, | 135 static void ParseModifyRequest(Json::Value& request, |
120 DicomModification& target, | 136 DicomModification& target, |
429 call.GetDocumentation() | 445 call.GetDocumentation() |
430 .SetTag("System") | 446 .SetTag("System") |
431 .SetSummary("Modify a set of resources") | 447 .SetSummary("Modify a set of resources") |
432 .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, | 448 .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, |
433 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) | 449 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) |
450 .SetRequestField(LEVEL, RestApiCallDocumentation::Type_String, | |
451 "Level of the modification (`Patient`, `Study`, `Series` or `Instance`). If absent, " | |
452 "the level defaults to `Instance`, but is set to `Patient` if `PatientID` is modified, " | |
453 "to `Study` if `StudyInstanceUID` is modified, or to `Series` if `SeriesInstancesUID` " | |
454 "is modified. (new in Orthanc 1.9.7)", false) | |
434 .SetDescription("Start a job that will modify all the DICOM patients, studies, series or instances " | 455 .SetDescription("Start a job that will modify all the DICOM patients, studies, series or instances " |
435 "whose identifiers are provided in the `Resources` field.") | 456 "whose identifiers are provided in the `Resources` field.") |
436 .AddAnswerType(MimeType_Json, "The list of all the resources that have been altered by this modification"); | 457 .AddAnswerType(MimeType_Json, "The list of all the resources that have been altered by this modification"); |
437 return; | 458 return; |
438 } | 459 } |
440 std::unique_ptr<DicomModification> modification(new DicomModification); | 461 std::unique_ptr<DicomModification> modification(new DicomModification); |
441 | 462 |
442 Json::Value body; | 463 Json::Value body; |
443 ParseModifyRequest(body, *modification, call); | 464 ParseModifyRequest(body, *modification, call); |
444 | 465 |
445 modification->SetLevel(DetectModifyLevel(*modification)); | 466 if (body.isMember(LEVEL)) |
467 { | |
468 // This case was introduced in Orthanc 1.9.7 | |
469 modification->SetLevel(StringToResourceType(body[LEVEL].asCString())); | |
470 } | |
471 else | |
472 { | |
473 modification->SetLevel(DetectModifyLevel(*modification)); | |
474 } | |
446 | 475 |
447 SubmitBulkJob(modification, false /* not an anonymization */, call, body); | 476 SubmitBulkJob(modification, false /* not an anonymization */, call, body); |
448 } | 477 } |
449 | 478 |
450 | 479 |