comparison OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 4424:83371ccdfe80

openapi documentation is now completed
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Dec 2020 19:28:53 +0100
parents 48303e493135
children 23ad1b9c7800
comparison
equal deleted inserted replaced
4423:2a69b58ff3ac 4424:83371ccdfe80
56 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence); 56 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence);
57 return "Anonymized" + boost::lexical_cast<std::string>(seq); 57 return "Anonymized" + boost::lexical_cast<std::string>(seq);
58 } 58 }
59 59
60 60
61 static void DocumentModifyOptions(RestApiPostCall& call)
62 {
63 // Check out "DicomModification::ParseModifyRequest()"
64 call.GetDocumentation()
65 .SetRequestField("Transcode", RestApiCallDocumentation::Type_String,
66 "Transcode the DICOM instances to the provided DICOM transfer syntax: "
67 "https://book.orthanc-server.com/faq/transcoding.html", false)
68 .SetRequestField("Force", RestApiCallDocumentation::Type_Boolean,
69 "Allow the modification of tags related to DICOM identifiers, at the risk of "
70 "breaking the DICOM model of the real world", false)
71 .SetRequestField("RemovePrivateTags", RestApiCallDocumentation::Type_Boolean,
72 "Remove the private tags from the DICOM instances (defaults to `false`)", false)
73 .SetRequestField("Replace", RestApiCallDocumentation::Type_JsonObject,
74 "Associative array to change the value of some DICOM tags in the DICOM instances", false)
75 .SetRequestField("Remove", RestApiCallDocumentation::Type_JsonListOfStrings,
76 "List of tags that must be removed from the DICOM instances", false)
77 .SetRequestField("Keep", RestApiCallDocumentation::Type_JsonListOfStrings,
78 "Keep the original value of the specified tags, to be chosen among the `StudyInstanceUID`, "
79 "`SeriesInstanceUID` and `SOPInstanceUID` tags. Avoid this feature as much as possible, "
80 "as this breaks the DICOM model of the real world.", false)
81 .SetRequestField("PrivateCreator", RestApiCallDocumentation::Type_String,
82 "The private creator to be used for private tags in `Replace`", false);
83 }
84
85
86 static void DocumentAnonymizationOptions(RestApiPostCall& call)
87 {
88 // Check out "DicomModification::ParseAnonymizationRequest()"
89 call.GetDocumentation()
90 .SetRequestField("Force", RestApiCallDocumentation::Type_Boolean,
91 "Allow the modification of tags related to DICOM identifiers, at the risk of "
92 "breaking the DICOM model of the real world", false)
93 .SetRequestField("DicomVersion", RestApiCallDocumentation::Type_String,
94 "Version of the DICOM standard to be used for anonymization. Check out "
95 "configuration option `DeidentifyLogsDicomVersion` for possible values.", false)
96 .SetRequestField("KeepPrivateTags", RestApiCallDocumentation::Type_Boolean,
97 "Keep the private tags from the DICOM instances (defaults to `false`)", false)
98 .SetRequestField("Replace", RestApiCallDocumentation::Type_JsonObject,
99 "Associative array to change the value of some DICOM tags in the DICOM instances", false)
100 .SetRequestField("Remove", RestApiCallDocumentation::Type_JsonListOfStrings,
101 "List of additional tags to be removed from the DICOM instances", false)
102 .SetRequestField("Keep", RestApiCallDocumentation::Type_JsonListOfStrings,
103 "List of DICOM tags whose value must not be destroyed by the anonymization", false)
104 .SetRequestField("PrivateCreator", RestApiCallDocumentation::Type_String,
105 "The private creator to be used for private tags in `Replace`", false);
106 }
107
108
61 static void ParseModifyRequest(Json::Value& request, 109 static void ParseModifyRequest(Json::Value& request,
62 DicomModification& target, 110 DicomModification& target,
63 const RestApiPostCall& call) 111 const RestApiPostCall& call)
64 { 112 {
65 // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"},"Priority":9}' 113 // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"},"Priority":9}'
157 } 205 }
158 206
159 207
160 static void ModifyInstance(RestApiPostCall& call) 208 static void ModifyInstance(RestApiPostCall& call)
161 { 209 {
210 if (call.IsDocumentation())
211 {
212 DocumentModifyOptions(call);
213 call.GetDocumentation()
214 .SetTag("Instance")
215 .SetSummary("Modify instance")
216 .SetDescription("Download a modified version of the DICOM instance whose Orthanc identifier is provided in the URL: "
217 "https://book.orthanc-server.com/users/anonymization.html#modification-of-a-single-instance")
218 .SetUriArgument("id", "Orthanc identifier of the instance of interest")
219 .AddAnswerType(MimeType_Dicom, "The modified DICOM instance");
220 return;
221 }
222
162 DicomModification modification; 223 DicomModification modification;
163 modification.SetAllowManualIdentifiers(true); 224 modification.SetAllowManualIdentifiers(true);
164 225
165 Json::Value request; 226 Json::Value request;
166 ParseModifyRequest(request, modification, call); 227 ParseModifyRequest(request, modification, call);
205 } 266 }
206 267
207 268
208 static void AnonymizeInstance(RestApiPostCall& call) 269 static void AnonymizeInstance(RestApiPostCall& call)
209 { 270 {
271 if (call.IsDocumentation())
272 {
273 DocumentAnonymizationOptions(call);
274 call.GetDocumentation()
275 .SetTag("Instance")
276 .SetSummary("Anonymize instance")
277 .SetDescription("Download an anonymized version of the DICOM instance whose Orthanc identifier is provided in the URL: "
278 "https://book.orthanc-server.com/users/anonymization.html#anonymization-of-a-single-instance")
279 .SetUriArgument("id", "Orthanc identifier of the instance of interest")
280 .AddAnswerType(MimeType_Dicom, "The anonymized DICOM instance");
281 return;
282 }
283
210 DicomModification modification; 284 DicomModification modification;
211 modification.SetAllowManualIdentifiers(true); 285 modification.SetAllowManualIdentifiers(true);
212 286
213 Json::Value request; 287 Json::Value request;
214 ParseAnonymizationRequest(request, modification, call); 288 ParseAnonymizationRequest(request, modification, call);
258 332
259 333
260 template <enum ResourceType resourceType> 334 template <enum ResourceType resourceType>
261 static void ModifyResource(RestApiPostCall& call) 335 static void ModifyResource(RestApiPostCall& call)
262 { 336 {
337 if (call.IsDocumentation())
338 {
339 OrthancRestApi::DocumentSubmitCommandsJob(call);
340 DocumentModifyOptions(call);
341 const std::string r = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */);
342 call.GetDocumentation()
343 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */))
344 .SetSummary("Modify " + r)
345 .SetDescription("Start a job that will modify all the DICOM instances within the " + r +
346 " whose identifier is provided in the URL. The modified DICOM instances will be "
347 "stored into a brand new " + r + ", whose Orthanc identifiers will be returned by the job. "
348 "https://book.orthanc-server.com/users/anonymization.html#modification-of-studies-or-series")
349 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest");
350 return;
351 }
352
263 std::unique_ptr<DicomModification> modification(new DicomModification); 353 std::unique_ptr<DicomModification> modification(new DicomModification);
264 354
265 Json::Value body; 355 Json::Value body;
266 ParseModifyRequest(body, *modification, call); 356 ParseModifyRequest(body, *modification, call);
267 357
273 363
274 364
275 template <enum ResourceType resourceType> 365 template <enum ResourceType resourceType>
276 static void AnonymizeResource(RestApiPostCall& call) 366 static void AnonymizeResource(RestApiPostCall& call)
277 { 367 {
368 if (call.IsDocumentation())
369 {
370 OrthancRestApi::DocumentSubmitCommandsJob(call);
371 DocumentAnonymizationOptions(call);
372 const std::string r = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */);
373 call.GetDocumentation()
374 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */))
375 .SetSummary("Anonymize " + r)
376 .SetDescription("Start a job that will anonymize all the DICOM instances within the " + r +
377 " whose identifier is provided in the URL. The modified DICOM instances will be "
378 "stored into a brand new " + r + ", whose Orthanc identifiers will be returned by the job. "
379 "https://book.orthanc-server.com/users/anonymization.html#anonymization-of-patients-studies-or-series")
380 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest");
381 return;
382 }
383
278 std::unique_ptr<DicomModification> modification(new DicomModification); 384 std::unique_ptr<DicomModification> modification(new DicomModification);
279 385
280 Json::Value body; 386 Json::Value body;
281 ParseAnonymizationRequest(body, *modification, call); 387 ParseAnonymizationRequest(body, *modification, call);
282 388
752 } 858 }
753 859
754 860
755 static void SplitStudy(RestApiPostCall& call) 861 static void SplitStudy(RestApiPostCall& call)
756 { 862 {
863 if (call.IsDocumentation())
864 {
865 OrthancRestApi::DocumentSubmitCommandsJob(call);
866 call.GetDocumentation()
867 .SetTag("Studies")
868 .SetSummary("Split study")
869 .SetDescription("Start a new job so as to split the DICOM study whose Orthanc identifier is provided in the URL, "
870 "by taking some of its children series out of it and putting them into a brand new study (this "
871 "new study is created by setting the `StudyInstanceUID` tag to a random identifier): "
872 "https://book.orthanc-server.com/users/anonymization.html#splitting")
873 .SetUriArgument("id", "Orthanc identifier of the study of interest")
874 .SetRequestField("Series", RestApiCallDocumentation::Type_JsonListOfStrings,
875 "The list of series to be separated from the parent study (mandatory option). "
876 "These series must all be children of the same source study, that is specified in the URI.", true)
877 .SetRequestField("Replace", RestApiCallDocumentation::Type_JsonObject,
878 "Associative array to change the value of some DICOM tags in the new study. "
879 "These tags must be part of the \"Patient Module Attributes\" or the \"General Study "
880 "Module Attributes\", as specified by the DICOM 2011 standard in Tables C.7-1 and C.7-3.", false)
881 .SetRequestField("Remove", RestApiCallDocumentation::Type_JsonListOfStrings,
882 "List of tags that must be removed in the new study (from the same modules as in the `Replace` option)", false)
883 .SetRequestField("KeepSource", RestApiCallDocumentation::Type_Boolean,
884 "If set to `true`, instructs Orthanc to keep a copy of the original series in the source study. "
885 "By default, the original series are deleted from Orthanc.", false);
886 return;
887 }
888
757 ServerContext& context = OrthancRestApi::GetContext(call); 889 ServerContext& context = OrthancRestApi::GetContext(call);
758 890
759 Json::Value request; 891 Json::Value request;
760 if (!call.ParseJsonRequest(request)) 892 if (!call.ParseJsonRequest(request))
761 { 893 {
831 } 963 }
832 964
833 965
834 static void MergeStudy(RestApiPostCall& call) 966 static void MergeStudy(RestApiPostCall& call)
835 { 967 {
968 if (call.IsDocumentation())
969 {
970 OrthancRestApi::DocumentSubmitCommandsJob(call);
971 call.GetDocumentation()
972 .SetTag("Studies")
973 .SetSummary("Merge study")
974 .SetDescription("Start a new job so as to move some DICOM series into the DICOM study whose Orthanc identifier "
975 "is provided in the URL: https://book.orthanc-server.com/users/anonymization.html#merging")
976 .SetUriArgument("id", "Orthanc identifier of the study of interest")
977 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings,
978 "The list of DICOM resources (patients, studies, series, and/or instances) to be merged "
979 "into the study of interest (mandatory option)", true)
980 .SetRequestField("KeepSource", RestApiCallDocumentation::Type_Boolean,
981 "If set to `true`, instructs Orthanc to keep a copy of the original resources in their source study. "
982 "By default, the original resources are deleted from Orthanc.", false);
983 return;
984 }
985
836 ServerContext& context = OrthancRestApi::GetContext(call); 986 ServerContext& context = OrthancRestApi::GetContext(call);
837 987
838 Json::Value request; 988 Json::Value request;
839 if (!call.ParseJsonRequest(request)) 989 if (!call.ParseJsonRequest(request))
840 { 990 {