Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 4495:fa2311f94d9f
IStorageArea::ReadRange()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Feb 2021 18:01:07 +0100 |
parents | 1619cffd1948 |
children | 8f9090b137f1 |
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 |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4435
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * 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
|
9 * published by the Free Software Foundation, either version 3 of the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * program give permission to link the code of its release with the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * 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
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * 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
|
30 * 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
|
31 **/ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
34 #include "../PrecompiledHeadersServer.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "OrthancRestApi.h" |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
4045 | 37 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
38 #include "../../../OrthancFramework/Sources/Logging.h" | |
39 #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
|
40 #include "../OrthancConfiguration.h" |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
41 #include "../ServerContext.h" |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
42 #include "../ServerJobs/MergeStudyJob.h" |
2642 | 43 #include "../ServerJobs/ResourceModificationJob.h" |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
44 #include "../ServerJobs/SplitStudyJob.h" |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
45 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
46 #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
|
47 #include <boost/algorithm/string/predicate.hpp> |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
48 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 // Modification of DICOM instances ------------------------------------------ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2518
diff
changeset
|
53 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 static std::string GeneratePatientName(ServerContext& context) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 return "Anonymized" + boost::lexical_cast<std::string>(seq); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
61 static void DocumentModifyOptions(RestApiPostCall& call) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
62 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
63 // Check out "DicomModification::ParseModifyRequest()" |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
64 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
65 .SetRequestField("Transcode", RestApiCallDocumentation::Type_String, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
66 "Transcode the DICOM instances to the provided DICOM transfer syntax: " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
67 "https://book.orthanc-server.com/faq/transcoding.html", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
68 .SetRequestField("Force", RestApiCallDocumentation::Type_Boolean, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
69 "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
|
70 "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
|
71 .SetRequestField("RemovePrivateTags", RestApiCallDocumentation::Type_Boolean, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
72 "Remove the private tags from the DICOM instances (defaults to `false`)", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
73 .SetRequestField("Replace", RestApiCallDocumentation::Type_JsonObject, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
74 "Associative array to change the value of some DICOM tags in the DICOM instances", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
75 .SetRequestField("Remove", RestApiCallDocumentation::Type_JsonListOfStrings, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
76 "List of tags that must be removed from the DICOM instances", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
77 .SetRequestField("Keep", RestApiCallDocumentation::Type_JsonListOfStrings, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
78 "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
|
79 "`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
|
80 "as this breaks the DICOM model of the real world.", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
81 .SetRequestField("PrivateCreator", RestApiCallDocumentation::Type_String, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
82 "The private creator to be used for private tags in `Replace`", false); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
83 } |
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 |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
86 static void DocumentAnonymizationOptions(RestApiPostCall& call) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
87 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
88 // Check out "DicomModification::ParseAnonymizationRequest()" |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
89 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
90 .SetRequestField("Force", RestApiCallDocumentation::Type_Boolean, |
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("DicomVersion", RestApiCallDocumentation::Type_String, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
94 "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
|
95 "configuration option `DeidentifyLogsDicomVersion` for possible values.", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
96 .SetRequestField("KeepPrivateTags", RestApiCallDocumentation::Type_Boolean, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
97 "Keep the private tags from the DICOM instances (defaults to `false`)", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
98 .SetRequestField("Replace", RestApiCallDocumentation::Type_JsonObject, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
99 "Associative array to change the value of some DICOM tags in the DICOM instances", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
100 .SetRequestField("Remove", RestApiCallDocumentation::Type_JsonListOfStrings, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
101 "List of additional tags to be removed from the DICOM instances", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
102 .SetRequestField("Keep", RestApiCallDocumentation::Type_JsonListOfStrings, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
103 "List of DICOM tags whose value must not be destroyed by the anonymization", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
104 .SetRequestField("PrivateCreator", RestApiCallDocumentation::Type_String, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
105 "The private creator to be used for private tags in `Replace`", false); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
106 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
107 |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
108 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
109 static void ParseModifyRequest(Json::Value& request, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
110 DicomModification& target, |
2517 | 111 const RestApiPostCall& call) |
112 { | |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
113 // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"},"Priority":9}' |
2517 | 114 |
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
|
115 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
116 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
|
117 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
|
118 } |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
119 |
2517 | 120 if (call.ParseJsonRequest(request)) |
121 { | |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2518
diff
changeset
|
122 target.ParseModifyRequest(request); |
2517 | 123 } |
124 else | |
125 { | |
126 throw OrthancException(ErrorCode_BadFileFormat); | |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2250
diff
changeset
|
127 } |
2517 | 128 } |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2250
diff
changeset
|
129 |
2517 | 130 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
131 static void ParseAnonymizationRequest(Json::Value& request, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
132 DicomModification& target, |
2517 | 133 RestApiPostCall& call) |
134 { | |
135 // 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 | |
136 | |
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
|
137 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
138 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
|
139 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
|
140 } |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
141 |
2517 | 142 if (call.ParseJsonRequest(request) && |
143 request.isObject()) | |
144 { | |
2518 | 145 bool patientNameReplaced; |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2518
diff
changeset
|
146 target.ParseAnonymizationRequest(patientNameReplaced, request); |
2518 | 147 |
148 if (patientNameReplaced) | |
149 { | |
150 // Overwrite the random Patient's Name by one that is more | |
151 // user-friendly (provided none was specified by the user) | |
152 target.Replace(DICOM_TAG_PATIENT_NAME, GeneratePatientName(OrthancRestApi::GetContext(call)), true); | |
153 } | |
2517 | 154 } |
155 else | |
156 { | |
157 throw OrthancException(ErrorCode_BadFileFormat); | |
158 } | |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
159 } |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
160 |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
161 |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
162 static void AnonymizeOrModifyInstance(DicomModification& modification, |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
163 RestApiPostCall& call, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
164 bool transcode, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
165 DicomTransferSyntax targetSyntax) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 { |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
167 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
|
168 std::string id = call.GetUriComponent("id", ""); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
170 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
|
171 |
2825
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
172 { |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
173 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
|
174 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
|
175 } |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
176 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
177 modification.Apply(*modified); |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
178 |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
179 if (transcode) |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
180 { |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
181 IDicomTranscoder::DicomImage source; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
182 source.AcquireParsed(*modified); // "modified" is invalid below this point |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
183 |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
184 IDicomTranscoder::DicomImage transcoded; |
3903
d1273d7cc200
avoid unnecessary dicom serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
185 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
186 std::set<DicomTransferSyntax> s; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
187 s.insert(targetSyntax); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
188 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
189 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
|
190 { |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
191 call.GetOutput().AnswerBuffer(transcoded.GetBufferData(), |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
192 transcoded.GetBufferSize(), MimeType_Dicom); |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
193 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
194 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
195 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
196 throw OrthancException(ErrorCode_InternalError, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
197 "Cannot transcode to transfer syntax: " + |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
198 std::string(GetTransferSyntaxUid(targetSyntax))); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
199 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
200 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
201 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
202 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
203 modified->Answer(call.GetOutput()); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
204 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 |
974 | 208 static void ModifyInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
210 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
211 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
212 DocumentModifyOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
213 call.GetDocumentation() |
4435
23ad1b9c7800
fix tag in openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4424
diff
changeset
|
214 .SetTag("Instances") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
215 .SetSummary("Modify instance") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
216 .SetDescription("Download a modified version of the DICOM instance whose Orthanc identifier is provided in the URL: " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
217 "https://book.orthanc-server.com/users/anonymization.html#modification-of-a-single-instance") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
218 .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
|
219 .AddAnswerType(MimeType_Dicom, "The modified DICOM instance"); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
220 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
221 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
222 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
223 DicomModification modification; |
1279
7f3a65e84d4b
More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1160
diff
changeset
|
224 modification.SetAllowManualIdentifiers(true); |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
225 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
226 Json::Value request; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
227 ParseModifyRequest(request, modification, call); |
2517 | 228 |
229 if (modification.IsReplaced(DICOM_TAG_PATIENT_ID)) | |
230 { | |
231 modification.SetLevel(ResourceType_Patient); | |
232 } | |
233 else if (modification.IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID)) | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 { |
2517 | 235 modification.SetLevel(ResourceType_Study); |
236 } | |
237 else if (modification.IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID)) | |
238 { | |
239 modification.SetLevel(ResourceType_Series); | |
240 } | |
241 else | |
242 { | |
243 modification.SetLevel(ResourceType_Instance); | |
244 } | |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
245 |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
246 static const char* TRANSCODE = "Transcode"; |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
247 if (request.isMember(TRANSCODE)) |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
248 { |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
249 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
|
250 |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
251 DicomTransferSyntax syntax; |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
252 if (LookupTransferSyntax(syntax, s)) |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
253 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
254 AnonymizeOrModifyInstance(modification, call, true, syntax); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
255 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
256 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
257 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
258 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
|
259 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
260 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
261 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
262 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
263 AnonymizeOrModifyInstance(modification, call, false /* no transcoding */, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
264 DicomTransferSyntax_LittleEndianImplicit /* unused */); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
265 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 |
974 | 269 static void AnonymizeInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
271 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
272 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
273 DocumentAnonymizationOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
274 call.GetDocumentation() |
4435
23ad1b9c7800
fix tag in openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4424
diff
changeset
|
275 .SetTag("Instances") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
276 .SetSummary("Anonymize instance") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
277 .SetDescription("Download an anonymized version of the DICOM instance whose Orthanc identifier is provided in the URL: " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
278 "https://book.orthanc-server.com/users/anonymization.html#anonymization-of-a-single-instance") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
279 .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
|
280 .AddAnswerType(MimeType_Dicom, "The anonymized DICOM instance"); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
281 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
282 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
283 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
284 DicomModification modification; |
1279
7f3a65e84d4b
More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1160
diff
changeset
|
285 modification.SetAllowManualIdentifiers(true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
287 Json::Value request; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
288 ParseAnonymizationRequest(request, modification, call); |
2517 | 289 |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
290 AnonymizeOrModifyInstance(modification, call, false /* no transcoding */, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
291 DicomTransferSyntax_LittleEndianImplicit /* unused */); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
295 static void SetKeepSource(CleaningInstancesJob& job, |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
296 const Json::Value& body) |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
297 { |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
298 static const char* KEEP_SOURCE = "KeepSource"; |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
299 if (body.isMember(KEEP_SOURCE)) |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
300 { |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
301 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
|
302 } |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
303 } |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
304 |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
305 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
306 static void SubmitModificationJob(std::unique_ptr<DicomModification>& modification, |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
307 bool isAnonymization, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
308 RestApiPostCall& call, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
309 const Json::Value& body, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
310 ResourceType level) |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
311 { |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
312 ServerContext& context = OrthancRestApi::GetContext(call); |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
313 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
314 std::unique_ptr<ResourceModificationJob> job(new ResourceModificationJob(context)); |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
315 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
316 job->SetModification(modification.release(), level, isAnonymization); |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
317 job->SetOrigin(call); |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
318 SetKeepSource(*job, body); |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
319 |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
320 static const char* TRANSCODE = "Transcode"; |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
321 if (body.isMember(TRANSCODE)) |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
322 { |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
323 job->SetTranscode(SerializationToolbox::ReadString(body, TRANSCODE)); |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
324 } |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
325 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
326 context.AddChildInstances(*job, call.GetUriComponent("id", "")); |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
327 job->AddTrailingStep(); |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
328 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
329 OrthancRestApi::GetApi(call).SubmitCommandsJob |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
330 (call, job.release(), true /* synchronous by default */, body); |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
331 } |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
332 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
333 |
2639 | 334 template <enum ResourceType resourceType> |
974 | 335 static void ModifyResource(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
337 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
338 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
339 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
340 DocumentModifyOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
341 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
|
342 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
343 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */)) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
344 .SetSummary("Modify " + r) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
345 .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
|
346 " 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
|
347 "stored into a brand new " + r + ", whose Orthanc identifiers will be returned by the job. " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
348 "https://book.orthanc-server.com/users/anonymization.html#modification-of-studies-or-series") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
349 .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
|
350 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
351 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
352 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
353 std::unique_ptr<DicomModification> modification(new DicomModification); |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
354 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
355 Json::Value body; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
356 ParseModifyRequest(body, *modification, call); |
2517 | 357 |
2639 | 358 modification->SetLevel(resourceType); |
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 SubmitModificationJob(modification, false /* not an anonymization */, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
361 call, body, resourceType); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 |
2639 | 365 template <enum ResourceType resourceType> |
974 | 366 static void AnonymizeResource(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
368 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
369 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
370 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
371 DocumentAnonymizationOptions(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
372 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
|
373 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
374 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */)) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
375 .SetSummary("Anonymize " + r) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
376 .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
|
377 " 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
|
378 "stored into a brand new " + r + ", whose Orthanc identifiers will be returned by the job. " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
379 "https://book.orthanc-server.com/users/anonymization.html#anonymization-of-patients-studies-or-series") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
380 .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
|
381 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
382 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
383 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
384 std::unique_ptr<DicomModification> modification(new DicomModification); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
386 Json::Value body; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
387 ParseAnonymizationRequest(body, *modification, call); |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
388 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
389 SubmitModificationJob(modification, true /* anonymization */, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
390 call, body, resourceType); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 |
1569 | 394 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
|
395 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
|
396 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
|
397 bool sendAnswer) |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
398 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
399 DicomInstanceToStore toStore; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2642
diff
changeset
|
400 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
401 toStore.SetParsedDicomFile(dicom); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
402 |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
403 ServerContext& context = OrthancRestApi::GetContext(call); |
3814
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
404 StoreStatus status = context.Store(id, toStore, StoreInstanceMode_Default); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
405 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
406 if (status == StoreStatus_Failure) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
407 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
408 throw OrthancException(ErrorCode_CannotStoreInstance); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
409 } |
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
|
410 |
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
|
411 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
|
412 { |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3910
diff
changeset
|
413 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status, 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
|
414 } |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
415 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
416 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
417 |
1569 | 418 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
|
419 RestApiPostCall& call, |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
420 const Json::Value& request) |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
421 { |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
422 // 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
|
423 // 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
|
424 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
425 assert(request.isObject()); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
426 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
|
427 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
428 Json::Value::Members members = request.getMemberNames(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
429 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
|
430 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
431 const std::string& name = members[i]; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
432 if (request[name].type() != Json::stringValue) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
433 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
434 throw OrthancException(ErrorCode_CreateDicomNotString); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
435 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
436 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
437 std::string value = request[name].asString(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
438 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
439 DicomTag tag = FromDcmtkBridge::ParseTag(name); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
440 if (tag == DICOM_TAG_PIXEL_DATA) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
441 { |
1562 | 442 dicom.EmbedContent(value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
443 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
444 else |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
445 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
446 // 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
|
447 dicom.ReplacePlainString(tag, value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
448 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
449 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
450 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
451 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
452 |
1569 | 453 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
|
454 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
|
455 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
|
456 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
|
457 bool force) |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
458 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
459 if (tags.type() != Json::objectValue) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
460 { |
2955 | 461 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
|
462 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
463 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
464 // Inject the user-specified tags |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
465 Json::Value::Members members = tags.getMemberNames(); |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
466 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
|
467 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
468 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
|
469 DicomTag tag = FromDcmtkBridge::ParseTag(name); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
470 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
471 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
|
472 { |
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
|
473 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
|
474 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
|
475 tag != DICOM_TAG_ACQUISITION_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
476 tag != DICOM_TAG_ACQUISITION_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
477 tag != DICOM_TAG_CONTENT_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
478 tag != DICOM_TAG_CONTENT_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
479 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
|
480 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
|
481 tag != DICOM_TAG_SERIES_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
482 tag != DICOM_TAG_SERIES_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
483 tag != DICOM_TAG_STUDY_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
484 tag != DICOM_TAG_STUDY_TIME && |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
485 dicom.HasTag(tag)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
486 { |
2952
4ceb9bf7b00c
added details string in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2936
diff
changeset
|
487 throw OrthancException(ErrorCode_CreateDicomOverrideTag, name); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
488 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
489 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
490 if (tag == DICOM_TAG_PIXEL_DATA) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
491 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
492 throw OrthancException(ErrorCode_CreateDicomUseContent); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
493 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
494 else |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
495 { |
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
|
496 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
|
497 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
498 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
499 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
500 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
501 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
502 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
503 static void CreateSeries(RestApiPostCall& call, |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
504 ParsedDicomFile& base /* in */, |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
505 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
|
506 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
|
507 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
|
508 bool force) |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
509 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
510 assert(content.isArray()); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
511 assert(content.size() > 0); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
512 ServerContext& context = OrthancRestApi::GetContext(call); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
513 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
514 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
|
515 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
|
516 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
517 std::string someInstance; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
518 |
1566 | 519 try |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
520 { |
1569 | 521 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
|
522 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
523 std::unique_ptr<ParsedDicomFile> dicom(base.Clone(false)); |
1566 | 524 const Json::Value* payload = NULL; |
525 | |
526 if (content[i].type() == Json::stringValue) | |
527 { | |
528 payload = &content[i]; | |
529 } | |
530 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
|
531 { |
1566 | 532 if (!content[i].isMember("Content")) |
533 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
534 throw OrthancException(ErrorCode_CreateDicomNoPayload); |
1566 | 535 } |
536 | |
537 payload = &content[i]["Content"]; | |
538 | |
1569 | 539 if (content[i].isMember("Tags")) |
1570 | 540 { |
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
|
541 InjectTags(*dicom, content[i]["Tags"], decodeBinaryTags, privateCreator, force); |
1570 | 542 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
543 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
544 |
1566 | 545 if (payload == NULL || |
546 payload->type() != Json::stringValue) | |
547 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
548 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); |
1566 | 549 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
550 |
1566 | 551 dicom->EmbedContent(payload->asString()); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
552 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
|
553 dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1)); |
1566 | 554 |
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
|
555 StoreCreatedInstance(someInstance, call, *dicom, false); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
556 } |
1566 | 557 } |
1616 | 558 catch (OrthancException&) |
1566 | 559 { |
1569 | 560 // Error: Remove the newly-created series |
561 | |
562 std::string series; | |
563 if (context.GetIndex().LookupParent(series, someInstance)) | |
1570 | 564 { |
1569 | 565 Json::Value dummy; |
566 context.GetIndex().DeleteResource(dummy, series, ResourceType_Series); | |
1570 | 567 } |
1569 | 568 |
1616 | 569 throw; |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
570 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
571 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
572 std::string series; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
573 if (context.GetIndex().LookupParent(series, someInstance)) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
574 { |
1569 | 575 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
|
576 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
577 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
578 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
579 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
580 static void CreateDicomV2(RestApiPostCall& call, |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
581 const Json::Value& request) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
582 { |
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
|
583 static const char* const CONTENT = "Content"; |
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
|
584 static const char* const FORCE = "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
|
585 static const char* const INTERPRET_BINARY_TAGS = "InterpretBinaryTags"; |
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
|
586 static const char* const PARENT = "Parent"; |
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
|
587 static const char* const PRIVATE_CREATOR = "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
|
588 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
|
589 static const char* const TAGS = "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
|
590 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
|
591 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
|
592 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
593 assert(request.isObject()); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
594 ServerContext& context = OrthancRestApi::GetContext(call); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
595 |
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
|
596 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
|
597 request[TAGS].type() != Json::objectValue) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
598 { |
1569 | 599 throw OrthancException(ErrorCode_BadRequest); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
600 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
601 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1699
diff
changeset
|
602 ParsedDicomFile dicom(true); |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
603 |
1557 | 604 { |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
605 Encoding encoding; |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
606 |
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
|
607 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
|
608 { |
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
|
609 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
|
610 if (!GetDicomEncoding(encoding, tmp)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
611 { |
2955 | 612 throw OrthancException(ErrorCode_ParameterOutOfRange, |
613 "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
|
614 } |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
615 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
616 else |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
617 { |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2361
diff
changeset
|
618 encoding = GetDefaultDicomEncoding(); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
619 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
620 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
621 dicom.SetEncoding(encoding); |
1557 | 622 } |
623 | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
624 ResourceType parentType = ResourceType_Instance; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
625 |
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
|
626 if (request.isMember(PARENT)) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
627 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
628 // 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
|
629 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
|
630 if (!context.GetIndex().LookupResourceType(parentType, parent)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
631 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
632 throw OrthancException(ErrorCode_CreateDicomBadParent); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
633 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
634 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
635 if (parentType == ResourceType_Instance) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
636 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
637 throw OrthancException(ErrorCode_CreateDicomParentIsInstance); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
638 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
639 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
640 // 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
|
641 // retrieve all its tags |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
642 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
|
643 std::string siblingInstanceId; |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
644 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
645 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
646 // 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
|
647 std::list<std::string> siblingInstances; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
648 context.GetIndex().GetChildInstances(siblingInstances, parent); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
649 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
650 if (siblingInstances.empty()) |
1569 | 651 { |
652 // Error: No instance (should never happen) | |
653 throw OrthancException(ErrorCode_InternalError); | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
654 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
655 |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
656 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
|
657 context.ReadDicomAsJson(siblingTags, siblingInstanceId); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
658 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
659 |
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 // 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
|
662 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
663 static const char* SPECIFIC_CHARACTER_SET = "0008,0005"; |
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 if (siblingTags.isMember(SPECIFIC_CHARACTER_SET)) |
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 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
|
668 |
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
|
669 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
|
670 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
|
671 !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
|
672 { |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
673 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
|
674 << "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
|
675 encoding = GetDefaultDicomEncoding(); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
676 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
677 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
678 dicom.SetEncoding(encoding); |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
679 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
680 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
681 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
682 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
683 // 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
|
684 typedef std::set<DicomTag> ModuleTags; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
685 ModuleTags moduleTags; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
686 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
687 ResourceType type = parentType; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
688 for (;;) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
689 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
690 DicomTag::AddTagsForModule(moduleTags, GetModule(type)); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
691 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
692 if (type == ResourceType_Patient) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
693 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
694 break; // We're done |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
695 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
696 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
697 // Go up |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
698 std::string tmp; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
699 if (!context.GetIndex().LookupParent(tmp, parent)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
700 { |
1569 | 701 throw OrthancException(ErrorCode_InternalError); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
702 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
703 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
704 parent = tmp; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
705 type = GetParentResourceType(type); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
706 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
707 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
708 for (ModuleTags::const_iterator it = moduleTags.begin(); |
1616 | 709 it != moduleTags.end(); ++it) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
710 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
711 std::string t = it->Format(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
712 if (siblingTags.isMember(t)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
713 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
714 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
|
715 if (tag[TYPE] == "Null") |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
716 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
717 dicom.ReplacePlainString(*it, ""); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
718 } |
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
|
719 else if (tag[TYPE] == "String") |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
720 { |
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
|
721 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
|
722 dicom.ReplacePlainString(*it, value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
723 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
724 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
725 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
726 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
727 |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
728 |
1689 | 729 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
|
730 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
|
731 { |
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
|
732 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
|
733 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
|
734 { |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
735 throw OrthancException(ErrorCode_BadRequest); |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
736 } |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
737 |
1689 | 738 decodeBinaryTags = v.asBool(); |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
739 } |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
740 |
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
|
741 |
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
|
742 // 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
|
743 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
|
744 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
|
745 { |
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
|
746 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
|
747 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
|
748 { |
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
|
749 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
|
750 } |
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
|
751 |
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
|
752 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
|
753 } |
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
|
754 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
|
755 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
756 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
|
757 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
|
758 } |
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
|
759 |
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
|
760 |
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
|
761 // 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
|
762 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
|
763 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
|
764 { |
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
|
765 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
|
766 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
|
767 { |
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 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
|
769 } |
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 |
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
|
771 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
|
772 } |
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
|
773 |
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
|
774 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
775 // Inject time-related information |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
776 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
|
777 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
|
778 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
|
779 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
|
780 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
|
781 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
|
782 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
|
783 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
|
784 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
785 if (parentType == ResourceType_Patient || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
786 parentType == ResourceType_Study || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
787 parentType == ResourceType_Instance /* no parent */) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
788 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
789 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
|
790 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
|
791 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
792 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
793 if (parentType == ResourceType_Patient || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
794 parentType == ResourceType_Instance /* no parent */) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
795 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
796 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
|
797 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
|
798 } |
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 |
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
|
801 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
|
802 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
803 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
804 // Inject the content (either an image, or a PDF 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
|
805 if (request.isMember(CONTENT)) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
806 { |
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
|
807 const Json::Value& content = request[CONTENT]; |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
808 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
809 if (content.type() == Json::stringValue) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
810 { |
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
|
811 dicom.EmbedContent(request[CONTENT].asString()); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
812 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
813 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
814 else if (content.type() == Json::arrayValue) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
815 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
816 if (content.size() > 0) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
817 { |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
818 // 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
|
819 CreateSeries(call, dicom, content, decodeBinaryTags, privateCreator, force); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
820 return; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
821 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
822 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
823 else |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
824 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
825 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
826 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
827 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
828 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
829 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
|
830 StoreCreatedInstance(id, call, dicom, true); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
831 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
832 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
833 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
834 static void CreateDicom(RestApiPostCall& call) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
835 { |
4422 | 836 if (call.IsDocumentation()) |
837 { | |
838 call.GetDocumentation() | |
839 .SetTag("System") | |
840 .SetSummary("Create one DICOM instance") | |
841 .SetDescription("Create one DICOM instance, and store it into Orthanc") | |
842 .SetRequestField("Tags", RestApiCallDocumentation::Type_JsonObject, | |
843 "Associative array containing the tags of the new instance to be created", true) | |
844 .SetRequestField("Content", RestApiCallDocumentation::Type_String, | |
845 "This field can be used to embed an image (pixel data) or a PDF inside the created DICOM instance. " | |
846 "The PNG image, the JPEG image or the PDF file must be provided using their " | |
847 "[data URI scheme encoding](https://en.wikipedia.org/wiki/Data_URI_scheme). " | |
848 "This field can possibly contain a JSON array, in which case a DICOM series is created " | |
849 "containing one DICOM instance for each item in the `Content` field.", false) | |
850 .SetRequestField("Parent", RestApiCallDocumentation::Type_String, | |
851 "If present, the newly created instance will be attached to the parent DICOM resource " | |
852 "whose Orthanc identifier is contained in this field. The DICOM tags of the parent " | |
853 "modules in the DICOM hierarchy will be automatically copied to the newly created instance.", false) | |
854 .SetRequestField("InterpretBinaryTags", RestApiCallDocumentation::Type_Boolean, | |
855 "If some value in the `Tags` associative array is formatted according to some " | |
856 "[data URI scheme encoding](https://en.wikipedia.org/wiki/Data_URI_scheme), " | |
857 "whether this value is decoded to a binary value or kept as such (`true` by default)", false) | |
858 .SetRequestField("PrivateCreator", RestApiCallDocumentation::Type_String, | |
859 "The private creator to be used for private tags in `Tags`", false) | |
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
|
860 .SetRequestField("Force", RestApiCallDocumentation::Type_Boolean, |
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
|
861 "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
|
862 "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
|
863 "`SeriesInstanceUID`, or `SOPInstanceUID`. Be careful with this feature.", false) |
4422 | 864 .SetAnswerField("ID", RestApiCallDocumentation::Type_String, "Orthanc identifier of the newly created instance") |
865 .SetAnswerField("Path", RestApiCallDocumentation::Type_String, "Path to access the instance in the REST API"); | |
866 return; | |
867 } | |
868 | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
869 Json::Value request; |
1569 | 870 if (!call.ParseJsonRequest(request) || |
871 !request.isObject()) | |
1570 | 872 { |
873 throw OrthancException(ErrorCode_BadRequest); | |
874 } | |
1569 | 875 |
876 if (request.isMember("Tags")) | |
1570 | 877 { |
878 CreateDicomV2(call, request); | |
879 } | |
1569 | 880 else |
1570 | 881 { |
882 // Compatibility with Orthanc <= 0.9.3 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1699
diff
changeset
|
883 ParsedDicomFile dicom(true); |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
884 CreateDicomV1(dicom, call, request); |
1569 | 885 |
1570 | 886 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
|
887 StoreCreatedInstance(id, call, dicom, true); |
1570 | 888 } |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
889 } |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
890 |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
891 |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
892 static void SplitStudy(RestApiPostCall& call) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
893 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
894 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
895 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
896 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
897 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
898 .SetTag("Studies") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
899 .SetSummary("Split study") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
900 .SetDescription("Start a new job so as to split the DICOM study whose Orthanc identifier is provided in the URL, " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
901 "by taking some of its children series out of it and putting them into a brand new study (this " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
902 "new study is created by setting the `StudyInstanceUID` tag to a random identifier): " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
903 "https://book.orthanc-server.com/users/anonymization.html#splitting") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
904 .SetUriArgument("id", "Orthanc identifier of the study of interest") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
905 .SetRequestField("Series", RestApiCallDocumentation::Type_JsonListOfStrings, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
906 "The list of series to be separated from the parent study (mandatory option). " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
907 "These series must all be children of the same source study, that is specified in the URI.", true) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
908 .SetRequestField("Replace", RestApiCallDocumentation::Type_JsonObject, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
909 "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
|
910 "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
|
911 "Module Attributes\", as specified by the DICOM 2011 standard in Tables C.7-1 and C.7-3.", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
912 .SetRequestField("Remove", RestApiCallDocumentation::Type_JsonListOfStrings, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
913 "List of tags that must be removed in the new study (from the same modules as in the `Replace` option)", false) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
914 .SetRequestField("KeepSource", RestApiCallDocumentation::Type_Boolean, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
915 "If set to `true`, instructs Orthanc to keep a copy of the original series in the source study. " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
916 "By default, the original series are deleted from Orthanc.", false); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
917 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
918 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
919 |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
920 ServerContext& context = OrthancRestApi::GetContext(call); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
921 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
922 Json::Value request; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
923 if (!call.ParseJsonRequest(request)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
924 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
925 // Bad JSON request |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
926 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
927 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
928 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
929 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
|
930 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
931 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
|
932 job->SetOrigin(call); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
933 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
934 std::vector<std::string> series; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
935 SerializationToolbox::ReadArrayOfStrings(series, request, "Series"); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
936 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
937 for (size_t i = 0; i < series.size(); i++) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
938 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
939 job->AddSourceSeries(series[i]); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
940 } |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
941 |
2860 | 942 job->AddTrailingStep(); |
943 | |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
944 SetKeepSource(*job, request); |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
945 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
946 static const char* REMOVE = "Remove"; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
947 if (request.isMember(REMOVE)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
948 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
949 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
|
950 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
951 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
952 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
953 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
954 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
|
955 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
956 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
|
957 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
958 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
959 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
960 else |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
961 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
962 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
|
963 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
964 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
965 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
966 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
967 static const char* REPLACE = "Replace"; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
968 if (request.isMember(REPLACE)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
969 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
970 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
|
971 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
972 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
973 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
974 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
975 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
|
976 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
977 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
|
978 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
979 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
|
980 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
981 if (value.type() != Json::stringValue) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
982 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
983 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
984 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
985 else |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
986 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
987 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
|
988 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
989 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
990 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
991 |
2869 | 992 OrthancRestApi::GetApi(call).SubmitCommandsJob |
993 (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
|
994 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
995 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
996 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
997 static void MergeStudy(RestApiPostCall& call) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
998 { |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
999 if (call.IsDocumentation()) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1000 { |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1001 OrthancRestApi::DocumentSubmitCommandsJob(call); |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1002 call.GetDocumentation() |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1003 .SetTag("Studies") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1004 .SetSummary("Merge study") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1005 .SetDescription("Start a new job so as to move some DICOM series into the DICOM study whose Orthanc identifier " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1006 "is provided in the URL: https://book.orthanc-server.com/users/anonymization.html#merging") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1007 .SetUriArgument("id", "Orthanc identifier of the study of interest") |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1008 .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1009 "The list of DICOM resources (patients, studies, series, and/or instances) to be merged " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1010 "into the study of interest (mandatory option)", true) |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1011 .SetRequestField("KeepSource", RestApiCallDocumentation::Type_Boolean, |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1012 "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
|
1013 "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
|
1014 return; |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1015 } |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4422
diff
changeset
|
1016 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1017 ServerContext& context = OrthancRestApi::GetContext(call); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1018 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1019 Json::Value request; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1020 if (!call.ParseJsonRequest(request)) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1021 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1022 // Bad JSON request |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1023 throw OrthancException(ErrorCode_BadFileFormat); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1024 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1025 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1026 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
|
1027 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
1028 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
|
1029 job->SetOrigin(call); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1030 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1031 std::vector<std::string> resources; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1032 SerializationToolbox::ReadArrayOfStrings(resources, request, "Resources"); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1033 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1034 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
|
1035 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1036 job->AddSource(resources[i]); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1037 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1038 |
2860 | 1039 job->AddTrailingStep(); |
1040 | |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
1041 SetKeepSource(*job, request); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1042 |
2869 | 1043 OrthancRestApi::GetApi(call).SubmitCommandsJob |
1044 (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
|
1045 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1046 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
1047 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1048 void OrthancRestApi::RegisterAnonymizeModify() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1049 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1050 Register("/instances/{id}/modify", ModifyInstance); |
2639 | 1051 Register("/series/{id}/modify", ModifyResource<ResourceType_Series>); |
1052 Register("/studies/{id}/modify", ModifyResource<ResourceType_Study>); | |
1053 Register("/patients/{id}/modify", ModifyResource<ResourceType_Patient>); | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1054 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1055 Register("/instances/{id}/anonymize", AnonymizeInstance); |
2639 | 1056 Register("/series/{id}/anonymize", AnonymizeResource<ResourceType_Series>); |
1057 Register("/studies/{id}/anonymize", AnonymizeResource<ResourceType_Study>); | |
1058 Register("/patients/{id}/anonymize", AnonymizeResource<ResourceType_Patient>); | |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
1059 |
1120
009dce4ea2f6
/tools/create-dicom now accepts PatientID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1010
diff
changeset
|
1060 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
|
1061 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
1062 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
|
1063 Register("/studies/{id}/merge", MergeStudy); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1064 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1065 } |