Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 5569:738f80622e91 find-refactoring
merge default -> find-refactoring
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 25 Apr 2024 17:07:33 +0200 |
parents | 4b3f5986eca1 |
children | f7adfb22e20e |
rev | line source |
---|---|
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5432
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5432
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * License, or (at your option) any later version. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
23 #include "../PrecompiledHeadersServer.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "OrthancRestApi.h" |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
4045 | 26 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
27 #include "../../../OrthancFramework/Sources/Logging.h" | |
28 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" | |
3709
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
29 #include "../OrthancConfiguration.h" |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
30 #include "../ServerContext.h" |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
31 #include "../ServerJobs/MergeStudyJob.h" |
2642 | 32 #include "../ServerJobs/ResourceModificationJob.h" |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
33 #include "../ServerJobs/SplitStudyJob.h" |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
34 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
35 #include <boost/lexical_cast.hpp> |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
36 #include <boost/algorithm/string/predicate.hpp> |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
37 |
4687
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
38 #define INFO_SUBSEQUENCES \ |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
39 "Starting with Orthanc 1.9.4, paths to subsequences can be provided using the "\ |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
40 "same syntax as the `dcmodify` command-line tool (wildcards are supported as well)." |
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
41 |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
42 |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
43 static const char* const CONTENT = "Content"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
44 static const char* const FORCE = "Force"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
45 static const char* const INSTANCES = "Instances"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
46 static const char* const INTERPRET_BINARY_TAGS = "InterpretBinaryTags"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
47 static const char* const KEEP = "Keep"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
48 static const char* const KEEP_PRIVATE_TAGS = "KeepPrivateTags"; |
5495
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
49 static const char* const KEEP_LABELS = "KeepLabels"; |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
50 static const char* const KEEP_SOURCE = "KeepSource"; |
4766
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
51 static const char* const LEVEL = "Level"; |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
52 static const char* const PARENT = "Parent"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
53 static const char* const PRIVATE_CREATOR = "PrivateCreator"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
54 static const char* const REMOVE = "Remove"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
55 static const char* const REPLACE = "Replace"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
56 static const char* const RESOURCES = "Resources"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
57 static const char* const SERIES = "Series"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
58 static const char* const TAGS = "Tags"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
59 static const char* const TRANSCODE = "Transcode"; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
60 |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
61 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 // Modification of DICOM instances ------------------------------------------ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2518
diff
changeset
|
66 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 static std::string GeneratePatientName(ServerContext& context) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
69 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence, true /* shared */); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 return "Anonymized" + boost::lexical_cast<std::string>(seq); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
4766
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
74 static void DocumentKeepSource(RestApiPostCall& call) |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
75 { |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
76 call.GetDocumentation() |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
77 .SetRequestField(KEEP_SOURCE, RestApiCallDocumentation::Type_Boolean, |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
78 "If set to `false`, instructs Orthanc to the remove original resources. " |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
79 "By default, the original resources are kept in Orthanc.", false); |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
80 } |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
81 |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
82 |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
83 static void DocumentModifyOptions(RestApiPostCall& call) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
84 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
85 // Check out "DicomModification::ParseModifyRequest()" |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
86 call.GetDocumentation() |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
87 .SetRequestField(TRANSCODE, RestApiCallDocumentation::Type_String, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
88 "Transcode the DICOM instances to the provided DICOM transfer syntax: " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
89 "https://orthanc.uclouvain.be/book/faq/transcoding.html", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
90 .SetRequestField(FORCE, RestApiCallDocumentation::Type_Boolean, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
91 "Allow the modification of tags related to DICOM identifiers, at the risk of " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
92 "breaking the DICOM model of the real world", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
93 .SetRequestField("RemovePrivateTags", RestApiCallDocumentation::Type_Boolean, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
94 "Remove the private tags from the DICOM instances (defaults to `false`)", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
95 .SetRequestField(REPLACE, RestApiCallDocumentation::Type_JsonObject, |
4687
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
96 "Associative array to change the value of some DICOM tags in the DICOM instances. " INFO_SUBSEQUENCES, false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
97 .SetRequestField(REMOVE, RestApiCallDocumentation::Type_JsonListOfStrings, |
4687
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
98 "List of tags that must be removed from the DICOM instances. " INFO_SUBSEQUENCES, false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
99 .SetRequestField(KEEP, RestApiCallDocumentation::Type_JsonListOfStrings, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
100 "Keep the original value of the specified tags, to be chosen among the `StudyInstanceUID`, " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
101 "`SeriesInstanceUID` and `SOPInstanceUID` tags. Avoid this feature as much as possible, " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
102 "as this breaks the DICOM model of the real world.", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
103 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
104 "The private creator to be used for private tags in `Replace`", false); |
4766
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
105 |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
106 // This was existing, but undocumented in Orthanc <= 1.9.6 |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
107 DocumentKeepSource(call); |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
108 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
109 |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
110 |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
111 static void DocumentAnonymizationOptions(RestApiPostCall& call) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
112 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
113 // Check out "DicomModification::ParseAnonymizationRequest()" |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
114 call.GetDocumentation() |
5148
2df546a76e17
If specifying 'Transcode' option to /modify or /anonymize, this value will take over the 'IngestTranscoding' global configuration
Alain Mazy <am@osimis.io>
parents:
5137
diff
changeset
|
115 .SetRequestField(TRANSCODE, RestApiCallDocumentation::Type_String, |
2df546a76e17
If specifying 'Transcode' option to /modify or /anonymize, this value will take over the 'IngestTranscoding' global configuration
Alain Mazy <am@osimis.io>
parents:
5137
diff
changeset
|
116 "Transcode the DICOM instances to the provided DICOM transfer syntax: " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
117 "https://orthanc.uclouvain.be/book/faq/transcoding.html", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
118 .SetRequestField(FORCE, RestApiCallDocumentation::Type_Boolean, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
119 "Allow the modification of tags related to DICOM identifiers, at the risk of " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
120 "breaking the DICOM model of the real world", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
121 .SetRequestField("DicomVersion", RestApiCallDocumentation::Type_String, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
122 "Version of the DICOM standard to be used for anonymization. Check out " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
123 "configuration option `DeidentifyLogsDicomVersion` for possible values.", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
124 .SetRequestField(KEEP_PRIVATE_TAGS, RestApiCallDocumentation::Type_Boolean, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
125 "Keep the private tags from the DICOM instances (defaults to `false`)", false) |
5495
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
126 .SetRequestField(KEEP_LABELS, RestApiCallDocumentation::Type_Boolean, |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
127 "Keep the labels of all resources level (defaults to `false`)", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
128 .SetRequestField(REPLACE, RestApiCallDocumentation::Type_JsonObject, |
4687
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
129 "Associative array to change the value of some DICOM tags in the DICOM instances. " INFO_SUBSEQUENCES, false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
130 .SetRequestField(REMOVE, RestApiCallDocumentation::Type_JsonListOfStrings, |
4687
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
131 "List of additional tags to be removed from the DICOM instances. " INFO_SUBSEQUENCES, false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
132 .SetRequestField(KEEP, RestApiCallDocumentation::Type_JsonListOfStrings, |
4687
fcd2dc7c8f31
"Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
133 "List of DICOM tags whose value must not be destroyed by the anonymization. " INFO_SUBSEQUENCES, false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
134 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
135 "The private creator to be used for private tags in `Replace`", false); |
4766
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
136 |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
137 // This was existing, but undocumented in Orthanc <= 1.9.6 |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
138 DocumentKeepSource(call); |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
139 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
140 |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
141 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
142 static void ParseModifyRequest(Json::Value& request, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
143 DicomModification& target, |
2517 | 144 const RestApiPostCall& call) |
145 { | |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
146 // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"},"Priority":9}' |
2517 | 147 |
3709
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
148 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
149 OrthancConfiguration::ReaderLock lock; |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
150 target.SetPrivateCreator(lock.GetConfiguration().GetDefaultPrivateCreator()); |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
151 } |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
152 |
2517 | 153 if (call.ParseJsonRequest(request)) |
154 { | |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2518
diff
changeset
|
155 target.ParseModifyRequest(request); |
2517 | 156 } |
157 else | |
158 { | |
159 throw OrthancException(ErrorCode_BadFileFormat); | |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2250
diff
changeset
|
160 } |
2517 | 161 } |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2250
diff
changeset
|
162 |
2517 | 163 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
164 static void ParseAnonymizationRequest(Json::Value& request, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
165 DicomModification& target, |
2517 | 166 RestApiPostCall& call) |
167 { | |
168 // curl http://localhost:8042/instances/6e67da51-d119d6ae-c5667437-87b9a8a5-0f07c49f/anonymize -X POST -d '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Remove":["Modality"]}' > Anonymized.dcm | |
169 | |
3709
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
170 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
171 OrthancConfiguration::ReaderLock lock; |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
172 target.SetPrivateCreator(lock.GetConfiguration().GetDefaultPrivateCreator()); |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
173 } |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
174 |
2517 | 175 if (call.ParseJsonRequest(request) && |
176 request.isObject()) | |
177 { | |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
178 bool patientNameOverridden; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
179 target.ParseAnonymizationRequest(patientNameOverridden, request); |
2518 | 180 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
181 if (!patientNameOverridden) |
2518 | 182 { |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
183 // Override the random Patient's Name by one that is more |
2518 | 184 // user-friendly (provided none was specified by the user) |
185 target.Replace(DICOM_TAG_PATIENT_NAME, GeneratePatientName(OrthancRestApi::GetContext(call)), true); | |
186 } | |
2517 | 187 } |
188 else | |
189 { | |
190 throw OrthancException(ErrorCode_BadFileFormat); | |
191 } | |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
192 } |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
193 |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
194 |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
195 static void AnonymizeOrModifyInstance(DicomModification& modification, |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
196 RestApiPostCall& call, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
197 bool transcode, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
198 DicomTransferSyntax targetSyntax) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 { |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
200 ServerContext& context = OrthancRestApi::GetContext(call); |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
751
diff
changeset
|
201 std::string id = call.GetUriComponent("id", ""); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
203 std::unique_ptr<ParsedDicomFile> modified; |
778
aebf0071020e
refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
751
diff
changeset
|
204 |
2825
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
205 { |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
206 ServerContext::DicomCacheLocker locker(context, id); |
2825
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
207 modified.reset(locker.GetDicom().Clone(true)); |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
208 } |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
209 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
210 modification.Apply(*modified); |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
211 |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
212 if (transcode) |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
213 { |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
214 IDicomTranscoder::DicomImage source; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
215 source.AcquireParsed(*modified); // "modified" is invalid below this point |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
216 |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
217 IDicomTranscoder::DicomImage transcoded; |
3903
d1273d7cc200
avoid unnecessary dicom serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
218 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
219 std::set<DicomTransferSyntax> s; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
220 s.insert(targetSyntax); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
221 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
222 if (context.Transcode(transcoded, source, s, true)) |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
223 { |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
224 call.GetOutput().AnswerBuffer(transcoded.GetBufferData(), |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
225 transcoded.GetBufferSize(), MimeType_Dicom); |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
226 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
227 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
228 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
229 throw OrthancException(ErrorCode_InternalError, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
230 "Cannot transcode to transfer syntax: " + |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
231 std::string(GetTransferSyntaxUid(targetSyntax))); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
232 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
233 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
234 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
235 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
236 modified->Answer(call.GetOutput()); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
237 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
241 static ResourceType DetectModifyLevel(const DicomModification& modification) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
242 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
243 if (modification.IsReplaced(DICOM_TAG_PATIENT_ID)) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
244 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
245 return ResourceType_Patient; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
246 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
247 else if (modification.IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID)) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
248 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
249 return ResourceType_Study; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
250 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
251 else if (modification.IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID)) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
252 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
253 return ResourceType_Series; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
254 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
255 else |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
256 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
257 return ResourceType_Instance; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
258 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
259 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
260 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
261 |
974 | 262 static void ModifyInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
264 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
265 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
266 DocumentModifyOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
267 call.GetDocumentation() |
4435
23ad1b9c7800
fix tag in openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4424
diff
changeset
|
268 .SetTag("Instances") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
269 .SetSummary("Modify instance") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
270 .SetDescription("Download a modified version of the DICOM instance whose Orthanc identifier is provided in the URL: " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
271 "https://orthanc.uclouvain.be/book/users/anonymization.html#modification-of-a-single-instance") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
272 .SetUriArgument("id", "Orthanc identifier of the instance of interest") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
273 .AddAnswerType(MimeType_Dicom, "The modified DICOM instance"); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
274 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
275 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
276 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
277 DicomModification modification; |
5122
8638522eeda1
revert changeset df4a90a65af9 that removes features used elsewhere, and protect by Force the change of UIDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5087
diff
changeset
|
278 modification.SetAllowManualIdentifiers(true); |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
279 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
280 Json::Value request; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
281 ParseModifyRequest(request, modification, call); |
2517 | 282 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
283 modification.SetLevel(DetectModifyLevel(modification)); |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
284 |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
285 if (request.isMember(TRANSCODE)) |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
286 { |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
287 std::string s = SerializationToolbox::ReadString(request, TRANSCODE); |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
288 |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
289 DicomTransferSyntax syntax; |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
290 if (LookupTransferSyntax(syntax, s)) |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
291 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
292 AnonymizeOrModifyInstance(modification, call, true, syntax); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
293 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
294 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
295 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
296 throw OrthancException(ErrorCode_ParameterOutOfRange, "Unknown transfer syntax: " + s); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
297 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
298 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
299 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
300 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
301 AnonymizeOrModifyInstance(modification, call, false /* no transcoding */, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
302 DicomTransferSyntax_LittleEndianImplicit /* unused */); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
303 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 |
974 | 307 static void AnonymizeInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
309 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
310 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
311 DocumentAnonymizationOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
312 call.GetDocumentation() |
4435
23ad1b9c7800
fix tag in openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4424
diff
changeset
|
313 .SetTag("Instances") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
314 .SetSummary("Anonymize instance") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
315 .SetDescription("Download an anonymized version of the DICOM instance whose Orthanc identifier is provided in the URL: " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
316 "https://orthanc.uclouvain.be/book/users/anonymization.html#anonymization-of-a-single-instance") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
317 .SetUriArgument("id", "Orthanc identifier of the instance of interest") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
318 .AddAnswerType(MimeType_Dicom, "The anonymized DICOM instance"); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
319 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
320 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
321 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
322 DicomModification modification; |
5122
8638522eeda1
revert changeset df4a90a65af9 that removes features used elsewhere, and protect by Force the change of UIDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5087
diff
changeset
|
323 modification.SetAllowManualIdentifiers(true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
325 Json::Value request; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
326 ParseAnonymizationRequest(request, modification, call); |
2517 | 327 |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
328 AnonymizeOrModifyInstance(modification, call, false /* no transcoding */, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
329 DicomTransferSyntax_LittleEndianImplicit /* unused */); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
333 static void SetKeepSource(CleaningInstancesJob& job, |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
334 const Json::Value& body) |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
335 { |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
336 if (body.isMember(KEEP_SOURCE)) |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
337 { |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
338 job.SetKeepSource(SerializationToolbox::ReadBoolean(body, KEEP_SOURCE)); |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
339 } |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
340 } |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
341 |
5130
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
342 static void SetKeepSource(ThreadedSetOfInstancesJob& job, |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
343 const Json::Value& body) |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
344 { |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
345 if (body.isMember(KEEP_SOURCE)) |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
346 { |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
347 job.SetKeepSource(SerializationToolbox::ReadBoolean(body, KEEP_SOURCE)); |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
348 } |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
349 } |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
350 |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
351 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
352 static void SubmitModificationJob(std::unique_ptr<DicomModification>& modification, |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
353 bool isAnonymization, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
354 RestApiPostCall& call, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
355 const Json::Value& body, |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
356 ResourceType outputLevel /* unused for multiple resources */, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
357 bool isSingleResource, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
358 const std::set<std::string>& resources) |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
359 { |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
360 ServerContext& context = OrthancRestApi::GetContext(call); |
5130
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
361 unsigned int workersCount = 0; |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
362 |
5130
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
363 { |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
364 OrthancConfiguration::ReaderLock lock; |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
365 workersCount = lock.GetConfiguration().GetJobsEngineWorkersThread("ResourceModification"); |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
366 } |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
367 |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
368 std::unique_ptr<ResourceModificationJob> job(new ResourceModificationJob(context, workersCount)); |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
369 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
370 if (isSingleResource) // This notably configures the output format |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
371 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
372 job->SetSingleResourceModification(modification.release(), outputLevel, isAnonymization); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
373 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
374 else |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
375 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
376 job->SetMultipleResourcesModification(modification.release(), isAnonymization); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
377 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
378 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
379 job->SetOrigin(call); |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
380 SetKeepSource(*job, body); |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
381 |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
382 if (body.isMember(TRANSCODE)) |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
383 { |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
384 job->SetTranscode(SerializationToolbox::ReadString(body, TRANSCODE)); |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
385 } |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
386 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
387 for (std::set<std::string>::const_iterator |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
388 it = resources.begin(); it != resources.end(); ++it) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
389 { |
5130
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
390 std::list<std::string> instances; |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
391 context.GetIndex().GetChildInstances(instances, *it); |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
392 job->AddInstances(instances); |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
393 |
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
394 job->AddParentResource(*it); |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
395 } |
5137
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
396 |
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
397 job->PerformSanityChecks(); |
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
398 |
5130
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
399 OrthancRestApi::GetApi(call).SubmitThreadedInstancesJob |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
400 (call, job.release(), true /* synchronous by default */, body); |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
401 } |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
402 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
403 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
404 static void SubmitModificationJob(std::unique_ptr<DicomModification>& modification, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
405 bool isAnonymization, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
406 RestApiPostCall& call, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
407 const Json::Value& body, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
408 ResourceType outputLevel) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
409 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
410 // This was the only flavor in Orthanc <= 1.9.3 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
411 std::set<std::string> resources; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
412 resources.insert(call.GetUriComponent("id", "")); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
413 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
414 SubmitModificationJob(modification, isAnonymization, call, body, outputLevel, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
415 true /* single resource */, resources); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
416 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
417 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
418 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
419 static void SubmitBulkJob(std::unique_ptr<DicomModification>& modification, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
420 bool isAnonymization, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
421 RestApiPostCall& call, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
422 const Json::Value& body) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
423 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
424 std::set<std::string> resources; |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
425 SerializationToolbox::ReadSetOfStrings(resources, body, RESOURCES); |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
426 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
427 SubmitModificationJob(modification, isAnonymization, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
428 call, body, ResourceType_Instance /* arbitrary value, unused */, |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
429 false /* multiple resources */, resources); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
430 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
431 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
432 |
2639 | 433 template <enum ResourceType resourceType> |
974 | 434 static void ModifyResource(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
436 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
437 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
438 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
439 DocumentModifyOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
440 const std::string r = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
441 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
442 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */)) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
443 .SetSummary("Modify " + r) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
444 .SetDescription("Start a job that will modify all the DICOM instances within the " + r + |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
445 " whose identifier is provided in the URL. The modified DICOM instances will be " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
446 "stored into a brand new " + r + ", whose Orthanc identifiers will be returned by the job. " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
447 "https://orthanc.uclouvain.be/book/users/anonymization.html#modification-of-studies-or-series") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
448 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest"); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
449 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
450 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
451 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
452 std::unique_ptr<DicomModification> modification(new DicomModification); |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
453 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
454 Json::Value body; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
455 ParseModifyRequest(body, *modification, call); |
2517 | 456 |
2639 | 457 modification->SetLevel(resourceType); |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
458 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
459 SubmitModificationJob(modification, false /* not an anonymization */, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
460 call, body, resourceType); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
464 // New in Orthanc 1.9.4 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
465 static void BulkModify(RestApiPostCall& call) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
466 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
467 if (call.IsDocumentation()) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
468 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
469 OrthancRestApi::DocumentSubmitCommandsJob(call); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
470 DocumentModifyOptions(call); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
471 call.GetDocumentation() |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
472 .SetTag("System") |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4693
diff
changeset
|
473 .SetSummary("Modify a set of resources") |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
474 .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, |
4699
facea16b055b
added the "Level" argument to "/tools/bulk-content"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4694
diff
changeset
|
475 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) |
4766
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
476 .SetRequestField(LEVEL, RestApiCallDocumentation::Type_String, |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
477 "Level of the modification (`Patient`, `Study`, `Series` or `Instance`). If absent, " |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
478 "the level defaults to `Instance`, but is set to `Patient` if `PatientID` is modified, " |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
479 "to `Study` if `StudyInstanceUID` is modified, or to `Series` if `SeriesInstancesUID` " |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
480 "is modified. (new in Orthanc 1.9.7)", false) |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
481 .SetDescription("Start a job that will modify all the DICOM patients, studies, series or instances " |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
482 "whose identifiers are provided in the `Resources` field.") |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
483 .AddAnswerType(MimeType_Json, "The list of all the resources that have been altered by this modification"); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
484 return; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
485 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
486 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
487 std::unique_ptr<DicomModification> modification(new DicomModification); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
488 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
489 Json::Value body; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
490 ParseModifyRequest(body, *modification, call); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
491 |
4766
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
492 if (body.isMember(LEVEL)) |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
493 { |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
494 // This case was introduced in Orthanc 1.9.7 |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
495 modification->SetLevel(StringToResourceType(body[LEVEL].asCString())); |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
496 } |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
497 else |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
498 { |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
499 modification->SetLevel(DetectModifyLevel(*modification)); |
388d108f6e4b
Added "Level" option to POST /tools/bulk-modify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4715
diff
changeset
|
500 } |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
501 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
502 SubmitBulkJob(modification, false /* not an anonymization */, call, body); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
503 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
504 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
505 |
2639 | 506 template <enum ResourceType resourceType> |
974 | 507 static void AnonymizeResource(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
509 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
510 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
511 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
512 DocumentAnonymizationOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
513 const std::string r = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
514 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
515 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */)) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
516 .SetSummary("Anonymize " + r) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
517 .SetDescription("Start a job that will anonymize all the DICOM instances within the " + r + |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
518 " whose identifier is provided in the URL. The modified DICOM instances will be " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
519 "stored into a brand new " + r + ", whose Orthanc identifiers will be returned by the job. " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
520 "https://orthanc.uclouvain.be/book/users/anonymization.html#anonymization-of-patients-studies-or-series") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
521 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest"); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
522 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
523 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
524 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
525 std::unique_ptr<DicomModification> modification(new DicomModification); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
527 Json::Value body; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
528 ParseAnonymizationRequest(body, *modification, call); |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
529 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
530 SubmitModificationJob(modification, true /* anonymization */, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
531 call, body, resourceType); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
535 // New in Orthanc 1.9.4 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
536 static void BulkAnonymize(RestApiPostCall& call) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
537 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
538 if (call.IsDocumentation()) |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
539 { |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
540 OrthancRestApi::DocumentSubmitCommandsJob(call); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
541 DocumentAnonymizationOptions(call); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
542 call.GetDocumentation() |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
543 .SetTag("System") |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4693
diff
changeset
|
544 .SetSummary("Anonymize a set of resources") |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
545 .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, |
4699
facea16b055b
added the "Level" argument to "/tools/bulk-content"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4694
diff
changeset
|
546 "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
547 .SetDescription("Start a job that will anonymize all the DICOM patients, studies, series or instances " |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
548 "whose identifiers are provided in the `Resources` field.") |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
549 .AddAnswerType(MimeType_Json, "The list of all the resources that have been created by this anonymization"); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
550 return; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
551 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
552 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
553 std::unique_ptr<DicomModification> modification(new DicomModification); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
554 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
555 Json::Value body; |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
556 ParseAnonymizationRequest(body, *modification, call); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
557 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
558 SubmitBulkJob(modification, true /* anonymization */, call, body); |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
559 } |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
560 |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
561 |
1569 | 562 static void StoreCreatedInstance(std::string& id /* out */, |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
563 RestApiPostCall& call, |
2899
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
564 ParsedDicomFile& dicom, |
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
565 bool sendAnswer) |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
566 { |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4479
diff
changeset
|
567 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(dicom)); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4479
diff
changeset
|
568 toStore->SetOrigin(DicomInstanceOrigin::FromRest(call)); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
569 |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
570 ServerContext& context = OrthancRestApi::GetContext(call); |
4796
94616af363ec
added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents:
4766
diff
changeset
|
571 ServerContext::StoreResult result = context.Store(id, *toStore, StoreInstanceMode_Default); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
572 |
4796
94616af363ec
added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents:
4766
diff
changeset
|
573 if (result.GetStatus() == StoreStatus_Failure) |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
574 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
575 throw OrthancException(ErrorCode_CannotStoreInstance); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
576 } |
2899
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
577 |
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
578 if (sendAnswer) |
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
579 { |
4796
94616af363ec
added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents:
4766
diff
changeset
|
580 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, *toStore, result.GetStatus(), id); |
2899
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
581 } |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
582 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
583 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
584 |
1569 | 585 static void CreateDicomV1(ParsedDicomFile& dicom, |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
586 RestApiPostCall& call, |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
587 const Json::Value& request) |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
588 { |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
589 // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}' |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
796
diff
changeset
|
590 // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World","PixelData":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="}' |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
591 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
592 assert(request.isObject()); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
593 LOG(WARNING) << "Using a deprecated call to /tools/create-dicom"; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
594 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
595 Json::Value::Members members = request.getMemberNames(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
596 for (size_t i = 0; i < members.size(); i++) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
597 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
598 const std::string& name = members[i]; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
599 if (request[name].type() != Json::stringValue) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
600 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
601 throw OrthancException(ErrorCode_CreateDicomNotString); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
602 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
603 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
604 std::string value = request[name].asString(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
605 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
606 DicomTag tag = FromDcmtkBridge::ParseTag(name); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
607 if (tag == DICOM_TAG_PIXEL_DATA) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
608 { |
1562 | 609 dicom.EmbedContent(value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
610 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
611 else |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
612 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
613 // This is V1, don't try and decode data URI scheme |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
614 dicom.ReplacePlainString(tag, value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
615 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
616 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
617 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
618 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
619 |
1569 | 620 static void InjectTags(ParsedDicomFile& dicom, |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
621 const Json::Value& tags, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
622 bool decodeBinaryTags, |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
623 const std::string& privateCreator, |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
624 bool force) |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
625 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
626 if (tags.type() != Json::objectValue) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
627 { |
2955 | 628 throw OrthancException(ErrorCode_BadRequest, "Tags field is not an array"); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
629 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
630 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
631 // Inject the user-specified tags |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
632 Json::Value::Members members = tags.getMemberNames(); |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
633 for (size_t i = 0; i < members.size(); i++) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
634 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
635 const std::string& name = members[i]; |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
636 DicomTag tag = FromDcmtkBridge::ParseTag(name); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
637 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
638 if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
639 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
640 if (!force && |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
641 tag != DICOM_TAG_PATIENT_ID && |
1640
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
642 tag != DICOM_TAG_ACQUISITION_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
643 tag != DICOM_TAG_ACQUISITION_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
644 tag != DICOM_TAG_CONTENT_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
645 tag != DICOM_TAG_CONTENT_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
646 tag != DICOM_TAG_INSTANCE_CREATION_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
647 tag != DICOM_TAG_INSTANCE_CREATION_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
648 tag != DICOM_TAG_SERIES_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
649 tag != DICOM_TAG_SERIES_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
650 tag != DICOM_TAG_STUDY_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
651 tag != DICOM_TAG_STUDY_TIME && |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
652 dicom.HasTag(tag)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
653 { |
2952
4ceb9bf7b00c
added details string in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2936
diff
changeset
|
654 throw OrthancException(ErrorCode_CreateDicomOverrideTag, name); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
655 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
656 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
657 if (tag == DICOM_TAG_PIXEL_DATA) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
658 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
659 throw OrthancException(ErrorCode_CreateDicomUseContent); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
660 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
661 else |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
662 { |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
663 dicom.Replace(tag, tags[name], decodeBinaryTags, DicomReplaceMode_InsertIfAbsent, privateCreator); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
664 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
665 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
666 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
667 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
668 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
669 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
670 static void CreateSeries(RestApiPostCall& call, |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
671 ParsedDicomFile& base /* in */, |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
672 const Json::Value& content, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
673 bool decodeBinaryTags, |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
674 const std::string& privateCreator, |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
675 bool force) |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
676 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
677 assert(content.isArray()); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
678 assert(content.size() > 0); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
679 ServerContext& context = OrthancRestApi::GetContext(call); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
680 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
681 base.ReplacePlainString(DICOM_TAG_IMAGES_IN_ACQUISITION, boost::lexical_cast<std::string>(content.size())); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
682 base.ReplacePlainString(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, "1"); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
683 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
684 std::string someInstance; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
685 |
1566 | 686 try |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
687 { |
1569 | 688 for (Json::ArrayIndex i = 0; i < content.size(); i++) |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
689 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
690 std::unique_ptr<ParsedDicomFile> dicom(base.Clone(false)); |
1566 | 691 const Json::Value* payload = NULL; |
692 | |
693 if (content[i].type() == Json::stringValue) | |
694 { | |
695 payload = &content[i]; | |
696 } | |
697 else if (content[i].type() == Json::objectValue) | |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
698 { |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
699 if (!content[i].isMember(CONTENT)) |
1566 | 700 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
701 throw OrthancException(ErrorCode_CreateDicomNoPayload); |
1566 | 702 } |
703 | |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
704 payload = &content[i][CONTENT]; |
1566 | 705 |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
706 if (content[i].isMember(TAGS)) |
1570 | 707 { |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
708 InjectTags(*dicom, content[i][TAGS], decodeBinaryTags, privateCreator, force); |
1570 | 709 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
710 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
711 |
1566 | 712 if (payload == NULL || |
713 payload->type() != Json::stringValue) | |
714 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
715 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); |
1566 | 716 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
717 |
1566 | 718 dicom->EmbedContent(payload->asString()); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
719 dicom->ReplacePlainString(DICOM_TAG_INSTANCE_NUMBER, boost::lexical_cast<std::string>(i + 1)); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
720 dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1)); |
1566 | 721 |
2899
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
722 StoreCreatedInstance(someInstance, call, *dicom, false); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
723 } |
1566 | 724 } |
1616 | 725 catch (OrthancException&) |
1566 | 726 { |
1569 | 727 // Error: Remove the newly-created series |
728 | |
729 std::string series; | |
730 if (context.GetIndex().LookupParent(series, someInstance)) | |
1570 | 731 { |
1569 | 732 Json::Value dummy; |
733 context.GetIndex().DeleteResource(dummy, series, ResourceType_Series); | |
1570 | 734 } |
1569 | 735 |
1616 | 736 throw; |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
737 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
738 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
739 std::string series; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
740 if (context.GetIndex().LookupParent(series, someInstance)) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
741 { |
1569 | 742 OrthancRestApi::GetApi(call).AnswerStoredResource(call, series, ResourceType_Series, StoreStatus_Success); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
743 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
744 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
745 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
746 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
747 static void CreateDicomV2(RestApiPostCall& call, |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
748 const Json::Value& request) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
749 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
750 static const char* const SPECIFIC_CHARACTER_SET_2 = "SpecificCharacterSet"; |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
751 static const char* const TYPE = "Type"; |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
752 static const char* const VALUE = "Value"; |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
753 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
754 assert(request.isObject()); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
755 ServerContext& context = OrthancRestApi::GetContext(call); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
756 |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
757 if (!request.isMember(TAGS) || |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
758 request[TAGS].type() != Json::objectValue) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
759 { |
1569 | 760 throw OrthancException(ErrorCode_BadRequest); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
761 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
762 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1699
diff
changeset
|
763 ParsedDicomFile dicom(true); |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
764 |
1557 | 765 { |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
766 Encoding encoding; |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
767 |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
768 if (request[TAGS].isMember(SPECIFIC_CHARACTER_SET_2)) |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
769 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
770 const char* tmp = request[TAGS][SPECIFIC_CHARACTER_SET_2].asCString(); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
771 if (!GetDicomEncoding(encoding, tmp)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
772 { |
2955 | 773 throw OrthancException(ErrorCode_ParameterOutOfRange, |
774 "Unknown specific character set: " + std::string(tmp)); | |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
775 } |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
776 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
777 else |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
778 { |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2361
diff
changeset
|
779 encoding = GetDefaultDicomEncoding(); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
780 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
781 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
782 dicom.SetEncoding(encoding); |
1557 | 783 } |
784 | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
785 ResourceType parentType = ResourceType_Instance; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
786 |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
787 if (request.isMember(PARENT)) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
788 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
789 // Locate the parent tags |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
790 std::string parent = request[PARENT].asString(); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
791 if (!context.GetIndex().LookupResourceType(parentType, parent)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
792 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
793 throw OrthancException(ErrorCode_CreateDicomBadParent); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
794 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
795 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
796 if (parentType == ResourceType_Instance) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
797 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
798 throw OrthancException(ErrorCode_CreateDicomParentIsInstance); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
799 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
800 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
801 // Select one existing child instance of the parent resource, to |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
802 // retrieve all its tags |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
803 Json::Value siblingTags; |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
804 std::string siblingInstanceId; |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
805 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
806 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
807 // Retrieve all the instances of the parent resource |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
808 std::list<std::string> siblingInstances; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
809 context.GetIndex().GetChildInstances(siblingInstances, parent); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
810 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
811 if (siblingInstances.empty()) |
1569 | 812 { |
813 // Error: No instance (should never happen) | |
814 throw OrthancException(ErrorCode_InternalError); | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
815 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
816 |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
817 siblingInstanceId = siblingInstances.front(); |
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
818 context.ReadDicomAsJson(siblingTags, siblingInstanceId); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
819 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
820 |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
821 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
822 // Choose the same encoding as the parent resource |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
823 { |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
824 static const char* const SPECIFIC_CHARACTER_SET = "0008,0005"; |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
825 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
826 if (siblingTags.isMember(SPECIFIC_CHARACTER_SET)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
827 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
828 Encoding encoding; |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
829 |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
830 if (!siblingTags[SPECIFIC_CHARACTER_SET].isMember(VALUE) || |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
831 siblingTags[SPECIFIC_CHARACTER_SET][VALUE].type() != Json::stringValue || |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
832 !GetDicomEncoding(encoding, siblingTags[SPECIFIC_CHARACTER_SET][VALUE].asCString())) |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
833 { |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
834 LOG(WARNING) << "Instance with an incorrect Specific Character Set, " |
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
835 << "using the default Orthanc encoding: " << siblingInstanceId; |
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
836 encoding = GetDefaultDicomEncoding(); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
837 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
838 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
839 dicom.SetEncoding(encoding); |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
840 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
841 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
842 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
843 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
844 // Retrieve the tags for all the parent modules |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
845 typedef std::set<DicomTag> ModuleTags; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
846 ModuleTags moduleTags; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
847 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
848 ResourceType type = parentType; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
849 for (;;) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
850 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
851 DicomTag::AddTagsForModule(moduleTags, GetModule(type)); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
852 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
853 if (type == ResourceType_Patient) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
854 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
855 break; // We're done |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
856 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
857 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
858 // Go up |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
859 std::string tmp; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
860 if (!context.GetIndex().LookupParent(tmp, parent)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
861 { |
1569 | 862 throw OrthancException(ErrorCode_InternalError); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
863 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
864 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
865 parent = tmp; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
866 type = GetParentResourceType(type); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
867 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
868 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
869 for (ModuleTags::const_iterator it = moduleTags.begin(); |
1616 | 870 it != moduleTags.end(); ++it) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
871 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
872 std::string t = it->Format(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
873 if (siblingTags.isMember(t)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
874 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
875 const Json::Value& tag = siblingTags[t]; |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
876 if (tag[TYPE] == "Null") |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
877 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
878 dicom.ReplacePlainString(*it, ""); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
879 } |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
880 else if (tag[TYPE] == "String") |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
881 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
882 std::string value = tag[VALUE].asString(); // This is an UTF-8 value (as it comes from JSON) |
3441
6cc72ebfd6ef
Fix issue #141 (/tools/create-dicom removes non-ASCII characters from study description)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
883 dicom.ReplacePlainString(*it, value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
884 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
885 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
886 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
887 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
888 |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
889 |
1689 | 890 bool decodeBinaryTags = true; |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
891 if (request.isMember(INTERPRET_BINARY_TAGS)) |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
892 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
893 const Json::Value& v = request[INTERPRET_BINARY_TAGS]; |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
894 if (v.type() != Json::booleanValue) |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
895 { |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
896 throw OrthancException(ErrorCode_BadRequest); |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
897 } |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
898 |
1689 | 899 decodeBinaryTags = v.asBool(); |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
900 } |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
901 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
902 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
903 // New argument in Orthanc 1.6.0 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
904 std::string privateCreator; |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
905 if (request.isMember(PRIVATE_CREATOR)) |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
906 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
907 const Json::Value& v = request[PRIVATE_CREATOR]; |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
908 if (v.type() != Json::stringValue) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
909 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
910 throw OrthancException(ErrorCode_BadRequest); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
911 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
912 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
913 privateCreator = v.asString(); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
914 } |
3709
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
915 else |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
916 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
917 OrthancConfiguration::ReaderLock lock; |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
918 privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator(); |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
919 } |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
920 |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
921 |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
922 // New in Orthanc 1.9.0 |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
923 bool force = false; |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
924 if (request.isMember(FORCE)) |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
925 { |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
926 const Json::Value& v = request[FORCE]; |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
927 if (v.type() != Json::booleanValue) |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
928 { |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
929 throw OrthancException(ErrorCode_BadRequest); |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
930 } |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
931 |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
932 force = v.asBool(); |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
933 } |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
934 |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
935 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
936 // Inject time-related information |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
937 std::string date, time; |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
938 SystemToolbox::GetNowDicom(date, time, true /* use UTC time (not local time) */); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
939 dicom.ReplacePlainString(DICOM_TAG_ACQUISITION_DATE, date); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
940 dicom.ReplacePlainString(DICOM_TAG_ACQUISITION_TIME, time); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
941 dicom.ReplacePlainString(DICOM_TAG_CONTENT_DATE, date); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
942 dicom.ReplacePlainString(DICOM_TAG_CONTENT_TIME, time); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
943 dicom.ReplacePlainString(DICOM_TAG_INSTANCE_CREATION_DATE, date); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
944 dicom.ReplacePlainString(DICOM_TAG_INSTANCE_CREATION_TIME, time); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
945 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
946 if (parentType == ResourceType_Patient || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
947 parentType == ResourceType_Study || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
948 parentType == ResourceType_Instance /* no parent */) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
949 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
950 dicom.ReplacePlainString(DICOM_TAG_SERIES_DATE, date); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
951 dicom.ReplacePlainString(DICOM_TAG_SERIES_TIME, time); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
952 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
953 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
954 if (parentType == ResourceType_Patient || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
955 parentType == ResourceType_Instance /* no parent */) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
956 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
957 dicom.ReplacePlainString(DICOM_TAG_STUDY_DATE, date); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
958 dicom.ReplacePlainString(DICOM_TAG_STUDY_TIME, time); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
959 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
960 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
961 |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
962 InjectTags(dicom, request[TAGS], decodeBinaryTags, privateCreator, force); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
963 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
964 |
5348
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
965 // Inject the content (either an image, a PDF file, or a STL/OBJ/MTL file) |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
966 if (request.isMember(CONTENT)) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
967 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
968 const Json::Value& content = request[CONTENT]; |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
969 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
970 if (content.type() == Json::stringValue) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
971 { |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
972 dicom.EmbedContent(request[CONTENT].asString()); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
973 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
974 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
975 else if (content.type() == Json::arrayValue) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
976 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
977 if (content.size() > 0) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
978 { |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
979 // Let's create a series instead of a single instance |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
980 CreateSeries(call, dicom, content, decodeBinaryTags, privateCreator, force); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
981 return; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
982 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
983 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
984 else |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
985 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
986 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
987 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
988 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
989 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
990 std::string id; |
2899
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
991 StoreCreatedInstance(id, call, dicom, true); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
992 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
993 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
994 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
995 static void CreateDicom(RestApiPostCall& call) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
996 { |
4422 | 997 if (call.IsDocumentation()) |
998 { | |
999 call.GetDocumentation() | |
1000 .SetTag("System") | |
1001 .SetSummary("Create one DICOM instance") | |
1002 .SetDescription("Create one DICOM instance, and store it into Orthanc") | |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1003 .SetRequestField(TAGS, RestApiCallDocumentation::Type_JsonObject, |
4422 | 1004 "Associative array containing the tags of the new instance to be created", true) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1005 .SetRequestField(CONTENT, RestApiCallDocumentation::Type_String, |
5348
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
1006 "This field can be used to embed an image (pixel data encoded as PNG or JPEG), a PDF, or a " |
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
1007 "3D manufactoring model (MTL/OBJ/STL) inside the created DICOM instance. " |
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
1008 "The file to be encapsulated must be provided using its " |
4422 | 1009 "[data URI scheme encoding](https://en.wikipedia.org/wiki/Data_URI_scheme). " |
1010 "This field can possibly contain a JSON array, in which case a DICOM series is created " | |
1011 "containing one DICOM instance for each item in the `Content` field.", false) | |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1012 .SetRequestField(PARENT, RestApiCallDocumentation::Type_String, |
4422 | 1013 "If present, the newly created instance will be attached to the parent DICOM resource " |
1014 "whose Orthanc identifier is contained in this field. The DICOM tags of the parent " | |
1015 "modules in the DICOM hierarchy will be automatically copied to the newly created instance.", false) | |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1016 .SetRequestField(INTERPRET_BINARY_TAGS, RestApiCallDocumentation::Type_Boolean, |
4422 | 1017 "If some value in the `Tags` associative array is formatted according to some " |
1018 "[data URI scheme encoding](https://en.wikipedia.org/wiki/Data_URI_scheme), " | |
1019 "whether this value is decoded to a binary value or kept as such (`true` by default)", false) | |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1020 .SetRequestField(PRIVATE_CREATOR, RestApiCallDocumentation::Type_String, |
4422 | 1021 "The private creator to be used for private tags in `Tags`", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1022 .SetRequestField(FORCE, RestApiCallDocumentation::Type_Boolean, |
4479
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1023 "Avoid the consistency checks for the DICOM tags that enforce the DICOM model of the real-world. " |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1024 "You can notably use this flag if you need to manually set the tags `StudyInstanceUID`, " |
1619cffd1948
"/tools/create-dicom": New flag "Force" to bypass consistency checks for the DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1025 "`SeriesInstanceUID`, or `SOPInstanceUID`. Be careful with this feature.", false) |
4422 | 1026 .SetAnswerField("ID", RestApiCallDocumentation::Type_String, "Orthanc identifier of the newly created instance") |
1027 .SetAnswerField("Path", RestApiCallDocumentation::Type_String, "Path to access the instance in the REST API"); | |
1028 return; | |
1029 } | |
1030 | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
1031 Json::Value request; |
1569 | 1032 if (!call.ParseJsonRequest(request) || |
1033 !request.isObject()) | |
1570 | 1034 { |
1035 throw OrthancException(ErrorCode_BadRequest); | |
1036 } | |
1569 | 1037 |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1038 if (request.isMember(TAGS)) |
1570 | 1039 { |
1040 CreateDicomV2(call, request); | |
1041 } | |
1569 | 1042 else |
1570 | 1043 { |
1044 // Compatibility with Orthanc <= 0.9.3 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1699
diff
changeset
|
1045 ParsedDicomFile dicom(true); |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
1046 CreateDicomV1(dicom, call, request); |
1569 | 1047 |
1570 | 1048 std::string id; |
2899
5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2869
diff
changeset
|
1049 StoreCreatedInstance(id, call, dicom, true); |
1570 | 1050 } |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
1051 } |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
1052 |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
1053 |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1054 static void SplitStudy(RestApiPostCall& call) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1055 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1056 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1057 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1058 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1059 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1060 .SetTag("Studies") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1061 .SetSummary("Split study") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1062 .SetDescription("Start a new job so as to split the DICOM study whose Orthanc identifier is provided in the URL, " |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1063 "by taking some of its children series or instances out of it and putting them into a brand new study " |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1064 "(this new study is created by setting the `StudyInstanceUID` tag to a random identifier): " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
1065 "https://orthanc.uclouvain.be/book/users/anonymization.html#splitting") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1066 .SetUriArgument("id", "Orthanc identifier of the study of interest") |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1067 .SetRequestField(SERIES, RestApiCallDocumentation::Type_JsonListOfStrings, |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1068 "The list of series to be separated from the parent study. " |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1069 "These series must all be children of the same source study, that is specified in the URI.", false) |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1070 .SetRequestField(REPLACE, RestApiCallDocumentation::Type_JsonObject, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1071 "Associative array to change the value of some DICOM tags in the new study. " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1072 "These tags must be part of the \"Patient Module Attributes\" or the \"General Study " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1073 "Module Attributes\", as specified by the DICOM 2011 standard in Tables C.7-1 and C.7-3.", false) |
5495
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
1074 .SetRequestField(KEEP_LABELS, RestApiCallDocumentation::Type_Boolean, |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
1075 "Keep the labels of all resources level (defaults to `false`)", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1076 .SetRequestField(REMOVE, RestApiCallDocumentation::Type_JsonListOfStrings, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1077 "List of tags that must be removed in the new study (from the same modules as in the `Replace` option)", false) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1078 .SetRequestField(KEEP_SOURCE, RestApiCallDocumentation::Type_Boolean, |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1079 "If set to `true`, instructs Orthanc to keep a copy of the original series/instances in the source study. " |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1080 "By default, the original series/instances are deleted from Orthanc.", false) |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1081 .SetRequestField(INSTANCES, RestApiCallDocumentation::Type_JsonListOfStrings, |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1082 "The list of instances to be separated from the parent study. " |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1083 "These instances must all be children of the same source study, that is specified in the URI.", false); |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1084 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1085 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1086 |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1087 ServerContext& context = OrthancRestApi::GetContext(call); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1088 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1089 Json::Value request; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1090 if (!call.ParseJsonRequest(request)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1091 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1092 // Bad JSON request |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1093 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1094 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1095 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1096 const std::string study = call.GetUriComponent("id", ""); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1097 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
1098 std::unique_ptr<SplitStudyJob> job(new SplitStudyJob(context, study)); |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1099 job->SetOrigin(call); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1100 |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1101 bool ok = false; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1102 if (request.isMember(SERIES)) |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1103 { |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1104 std::vector<std::string> series; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1105 SerializationToolbox::ReadArrayOfStrings(series, request, SERIES); |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1106 |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1107 for (size_t i = 0; i < series.size(); i++) |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1108 { |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1109 job->AddSourceSeries(series[i]); |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1110 ok = true; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1111 } |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1112 } |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1113 |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1114 if (request.isMember(INSTANCES)) |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1115 { |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1116 std::vector<std::string> instances; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1117 SerializationToolbox::ReadArrayOfStrings(instances, request, INSTANCES); |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1118 |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1119 for (size_t i = 0; i < instances.size(); i++) |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1120 { |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1121 job->AddSourceInstance(instances[i]); |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1122 ok = true; |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1123 } |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1124 } |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1125 |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1126 if (!ok) |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1127 { |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1128 throw OrthancException(ErrorCode_BadRequest, "Both the \"Series\" and the \"Instances\" fields are missing"); |
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1129 } |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1130 |
2860 | 1131 job->AddTrailingStep(); |
1132 | |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1133 SetKeepSource(*job, request); |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1134 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1135 if (request.isMember(REMOVE)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1136 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1137 if (request[REMOVE].type() != Json::arrayValue) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1138 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1139 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1140 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1141 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1142 for (Json::Value::ArrayIndex i = 0; i < request[REMOVE].size(); i++) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1143 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1144 if (request[REMOVE][i].type() != Json::stringValue) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1145 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1146 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1147 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1148 else |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1149 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1150 job->Remove(FromDcmtkBridge::ParseTag(request[REMOVE][i].asCString())); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1151 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1152 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1153 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1154 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1155 if (request.isMember(REPLACE)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1156 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1157 if (request[REPLACE].type() != Json::objectValue) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1158 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1159 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1160 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1161 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1162 Json::Value::Members tags = request[REPLACE].getMemberNames(); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1163 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1164 for (size_t i = 0; i < tags.size(); i++) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1165 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1166 const Json::Value& value = request[REPLACE][tags[i]]; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1167 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1168 if (value.type() != Json::stringValue) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1169 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1170 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1171 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1172 else |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1173 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1174 job->Replace(FromDcmtkBridge::ParseTag(tags[i]), value.asString()); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1175 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1176 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1177 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1178 |
2869 | 1179 OrthancRestApi::GetApi(call).SubmitCommandsJob |
1180 (call, job.release(), true /* synchronous by default */, request); | |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1181 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1182 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1183 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1184 static void MergeStudy(RestApiPostCall& call) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1185 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1186 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1187 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1188 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1189 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1190 .SetTag("Studies") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1191 .SetSummary("Merge study") |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4712
diff
changeset
|
1192 .SetDescription("Start a new job so as to move some DICOM resources into the DICOM study whose Orthanc identifier " |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5348
diff
changeset
|
1193 "is provided in the URL: https://orthanc.uclouvain.be/book/users/anonymization.html#merging") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1194 .SetUriArgument("id", "Orthanc identifier of the study of interest") |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1195 .SetRequestField(RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, |
4715
fb98db281d1d
"/studies/{id}/merge" accepts instances inside its "Resources" parameter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4712
diff
changeset
|
1196 "The list of DICOM resources (studies, series, and/or instances) to be merged " |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1197 "into the study of interest (mandatory option)", true) |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1198 .SetRequestField(KEEP_SOURCE, RestApiCallDocumentation::Type_Boolean, |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1199 "If set to `true`, instructs Orthanc to keep a copy of the original resources in their source study. " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1200 "By default, the original resources are deleted from Orthanc.", false); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1201 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1202 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1203 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1204 ServerContext& context = OrthancRestApi::GetContext(call); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1205 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1206 Json::Value request; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1207 if (!call.ParseJsonRequest(request)) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1208 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1209 // Bad JSON request |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1210 throw OrthancException(ErrorCode_BadFileFormat); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1211 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1212 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1213 const std::string study = call.GetUriComponent("id", ""); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1214 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
1215 std::unique_ptr<MergeStudyJob> job(new MergeStudyJob(context, study)); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1216 job->SetOrigin(call); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1217 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1218 std::vector<std::string> resources; |
4712
bad8935cd5f2
"/studies/{id}/split" accepts "Instances" parameter to split instances instead of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4699
diff
changeset
|
1219 SerializationToolbox::ReadArrayOfStrings(resources, request, RESOURCES); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1220 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1221 for (size_t i = 0; i < resources.size(); i++) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1222 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1223 job->AddSource(resources[i]); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1224 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1225 |
2860 | 1226 job->AddTrailingStep(); |
1227 | |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1228 SetKeepSource(*job, request); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1229 |
2869 | 1230 OrthancRestApi::GetApi(call).SubmitCommandsJob |
1231 (call, job.release(), true /* synchronous by default */, request); | |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1232 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1233 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1234 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1235 void OrthancRestApi::RegisterAnonymizeModify() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1236 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1237 Register("/instances/{id}/modify", ModifyInstance); |
2639 | 1238 Register("/series/{id}/modify", ModifyResource<ResourceType_Series>); |
1239 Register("/studies/{id}/modify", ModifyResource<ResourceType_Study>); | |
1240 Register("/patients/{id}/modify", ModifyResource<ResourceType_Patient>); | |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1241 Register("/tools/bulk-modify", BulkModify); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1242 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1243 Register("/instances/{id}/anonymize", AnonymizeInstance); |
2639 | 1244 Register("/series/{id}/anonymize", AnonymizeResource<ResourceType_Series>); |
1245 Register("/studies/{id}/anonymize", AnonymizeResource<ResourceType_Study>); | |
1246 Register("/patients/{id}/anonymize", AnonymizeResource<ResourceType_Patient>); | |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4687
diff
changeset
|
1247 Register("/tools/bulk-anonymize", BulkAnonymize); |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
1248 |
1120
009dce4ea2f6
/tools/create-dicom now accepts PatientID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1010
diff
changeset
|
1249 Register("/tools/create-dicom", CreateDicom); |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1250 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1251 Register("/studies/{id}/split", SplitStudy); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1252 Register("/studies/{id}/merge", MergeStudy); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1253 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1254 } |