Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 4051:c459f210f6ac framework
removed ORTHANC_ROOT
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 11 Jun 2020 11:51:03 +0200 |
parents | 05b8fd21089c |
children | 48303e493135 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3441
diff
changeset
|
5 * Copyright (C) 2017-2020 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 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
61 static void ParseModifyRequest(Json::Value& request, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
62 DicomModification& target, |
2517 | 63 const RestApiPostCall& call) |
64 { | |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
65 // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"},"Priority":9}' |
2517 | 66 |
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
|
67 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
68 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
|
69 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
|
70 } |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
71 |
2517 | 72 if (call.ParseJsonRequest(request)) |
73 { | |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2518
diff
changeset
|
74 target.ParseModifyRequest(request); |
2517 | 75 } |
76 else | |
77 { | |
78 throw OrthancException(ErrorCode_BadFileFormat); | |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2250
diff
changeset
|
79 } |
2517 | 80 } |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2250
diff
changeset
|
81 |
2517 | 82 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
83 static void ParseAnonymizationRequest(Json::Value& request, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
84 DicomModification& target, |
2517 | 85 RestApiPostCall& call) |
86 { | |
87 // 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 | |
88 | |
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
|
89 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
90 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
|
91 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
|
92 } |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
93 |
2517 | 94 if (call.ParseJsonRequest(request) && |
95 request.isObject()) | |
96 { | |
2518 | 97 bool patientNameReplaced; |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2518
diff
changeset
|
98 target.ParseAnonymizationRequest(patientNameReplaced, request); |
2518 | 99 |
100 if (patientNameReplaced) | |
101 { | |
102 // Overwrite the random Patient's Name by one that is more | |
103 // user-friendly (provided none was specified by the user) | |
104 target.Replace(DICOM_TAG_PATIENT_NAME, GeneratePatientName(OrthancRestApi::GetContext(call)), true); | |
105 } | |
2517 | 106 } |
107 else | |
108 { | |
109 throw OrthancException(ErrorCode_BadFileFormat); | |
110 } | |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
111 } |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
112 |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
113 |
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
114 static void AnonymizeOrModifyInstance(DicomModification& modification, |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
115 RestApiPostCall& call, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
116 bool transcode, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
117 DicomTransferSyntax targetSyntax) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 { |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
119 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
|
120 std::string id = call.GetUriComponent("id", ""); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
122 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
|
123 |
2825
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
124 { |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
125 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
|
126 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
|
127 } |
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
128 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
129 modification.Apply(*modified); |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
130 |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
131 if (transcode) |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
132 { |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
133 IDicomTranscoder::DicomImage source; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
134 source.AcquireParsed(*modified); // "modified" is invalid below this point |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
135 |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
136 IDicomTranscoder::DicomImage transcoded; |
3903
d1273d7cc200
avoid unnecessary dicom serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
137 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
138 std::set<DicomTransferSyntax> s; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
139 s.insert(targetSyntax); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
140 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
141 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
|
142 { |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
143 call.GetOutput().AnswerBuffer(transcoded.GetBufferData(), |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3943
diff
changeset
|
144 transcoded.GetBufferSize(), MimeType_Dicom); |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
145 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
146 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
147 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
148 throw OrthancException(ErrorCode_InternalError, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
149 "Cannot transcode to transfer syntax: " + |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
150 std::string(GetTransferSyntaxUid(targetSyntax))); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
151 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
152 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
153 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
154 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
155 modified->Answer(call.GetOutput()); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
156 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
974 | 160 static void ModifyInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 { |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
162 DicomModification modification; |
1279
7f3a65e84d4b
More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1160
diff
changeset
|
163 modification.SetAllowManualIdentifiers(true); |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
164 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
165 Json::Value request; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
166 ParseModifyRequest(request, modification, call); |
2517 | 167 |
168 if (modification.IsReplaced(DICOM_TAG_PATIENT_ID)) | |
169 { | |
170 modification.SetLevel(ResourceType_Patient); | |
171 } | |
172 else if (modification.IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID)) | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 { |
2517 | 174 modification.SetLevel(ResourceType_Study); |
175 } | |
176 else if (modification.IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID)) | |
177 { | |
178 modification.SetLevel(ResourceType_Series); | |
179 } | |
180 else | |
181 { | |
182 modification.SetLevel(ResourceType_Instance); | |
183 } | |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
184 |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
185 static const char* TRANSCODE = "Transcode"; |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
186 if (request.isMember(TRANSCODE)) |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
187 { |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
188 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
|
189 |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
190 DicomTransferSyntax syntax; |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
191 if (LookupTransferSyntax(syntax, s)) |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
192 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
193 AnonymizeOrModifyInstance(modification, call, true, syntax); |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
194 } |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
195 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
196 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
197 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
|
198 } |
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 else |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
201 { |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
202 AnonymizeOrModifyInstance(modification, call, false /* no transcoding */, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
203 DicomTransferSyntax_LittleEndianImplicit /* unused */); |
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 AnonymizeInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 { |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
210 DicomModification modification; |
1279
7f3a65e84d4b
More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1160
diff
changeset
|
211 modification.SetAllowManualIdentifiers(true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
213 Json::Value request; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
214 ParseAnonymizationRequest(request, modification, call); |
2517 | 215 |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
216 AnonymizeOrModifyInstance(modification, call, false /* no transcoding */, |
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3814
diff
changeset
|
217 DicomTransferSyntax_LittleEndianImplicit /* unused */); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
221 static void SetKeepSource(CleaningInstancesJob& job, |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
222 const Json::Value& body) |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
223 { |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
224 static const char* KEEP_SOURCE = "KeepSource"; |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
225 if (body.isMember(KEEP_SOURCE)) |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
226 { |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
227 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
|
228 } |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
229 } |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
230 |
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
231 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
232 static void SubmitModificationJob(std::unique_ptr<DicomModification>& modification, |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
233 bool isAnonymization, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
234 RestApiPostCall& call, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
235 const Json::Value& body, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
236 ResourceType level) |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
237 { |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
238 ServerContext& context = OrthancRestApi::GetContext(call); |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
239 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
240 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
|
241 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
242 job->SetModification(modification.release(), level, isAnonymization); |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
243 job->SetOrigin(call); |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
244 SetKeepSource(*job, body); |
3943
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
245 |
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 (body.isMember(TRANSCODE)) |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
248 { |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
249 job->SetTranscode(SerializationToolbox::ReadString(body, TRANSCODE)); |
b26d25d3c1c7
"/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3942
diff
changeset
|
250 } |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
251 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
252 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
|
253 job->AddTrailingStep(); |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
254 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
255 OrthancRestApi::GetApi(call).SubmitCommandsJob |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
256 (call, job.release(), true /* synchronous by default */, body); |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
257 } |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
258 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
259 |
2639 | 260 template <enum ResourceType resourceType> |
974 | 261 static void ModifyResource(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
263 std::unique_ptr<DicomModification> modification(new DicomModification); |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
264 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
265 Json::Value body; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
266 ParseModifyRequest(body, *modification, call); |
2517 | 267 |
2639 | 268 modification->SetLevel(resourceType); |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
269 |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
270 SubmitModificationJob(modification, false /* not an anonymization */, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
271 call, body, resourceType); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 |
2639 | 275 template <enum ResourceType resourceType> |
974 | 276 static void AnonymizeResource(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
278 std::unique_ptr<DicomModification> modification(new DicomModification); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
280 Json::Value body; |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
281 ParseAnonymizationRequest(body, *modification, call); |
2640
c691fcf66071
ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2639
diff
changeset
|
282 |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
283 SubmitModificationJob(modification, true /* anonymization */, |
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
284 call, body, resourceType); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 |
1569 | 288 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
|
289 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
|
290 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
|
291 bool sendAnswer) |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
292 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
293 DicomInstanceToStore toStore; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2642
diff
changeset
|
294 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
295 toStore.SetParsedDicomFile(dicom); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
296 |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
297 ServerContext& context = OrthancRestApi::GetContext(call); |
3814
023b2a9f3aa1
new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
298 StoreStatus status = context.Store(id, toStore, StoreInstanceMode_Default); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
299 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
300 if (status == StoreStatus_Failure) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
301 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
302 throw OrthancException(ErrorCode_CannotStoreInstance); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
303 } |
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
|
304 |
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
|
305 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
|
306 { |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3910
diff
changeset
|
307 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
|
308 } |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
309 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
310 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
311 |
1569 | 312 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
|
313 RestApiPostCall& call, |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
314 const Json::Value& request) |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
315 { |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
316 // 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
|
317 // 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
|
318 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
319 assert(request.isObject()); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
320 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
|
321 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
322 Json::Value::Members members = request.getMemberNames(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
323 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
|
324 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
325 const std::string& name = members[i]; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
326 if (request[name].type() != Json::stringValue) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
327 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
328 throw OrthancException(ErrorCode_CreateDicomNotString); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
329 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
330 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
331 std::string value = request[name].asString(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
332 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
333 DicomTag tag = FromDcmtkBridge::ParseTag(name); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
334 if (tag == DICOM_TAG_PIXEL_DATA) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
335 { |
1562 | 336 dicom.EmbedContent(value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
337 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
338 else |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
339 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
340 // 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
|
341 dicom.ReplacePlainString(tag, value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
342 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
343 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
344 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
345 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
346 |
1569 | 347 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
|
348 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
|
349 bool decodeBinaryTags, |
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
|
350 const std::string& privateCreator) |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
351 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
352 if (tags.type() != Json::objectValue) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
353 { |
2955 | 354 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
|
355 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
356 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
357 // Inject the user-specified tags |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
358 Json::Value::Members members = tags.getMemberNames(); |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
359 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
|
360 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
361 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
|
362 DicomTag tag = FromDcmtkBridge::ParseTag(name); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
363 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
364 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
|
365 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
366 if (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
|
367 tag != DICOM_TAG_ACQUISITION_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
368 tag != DICOM_TAG_ACQUISITION_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
369 tag != DICOM_TAG_CONTENT_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
370 tag != DICOM_TAG_CONTENT_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
371 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
|
372 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
|
373 tag != DICOM_TAG_SERIES_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
374 tag != DICOM_TAG_SERIES_TIME && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
375 tag != DICOM_TAG_STUDY_DATE && |
48224db51ee7
allow override date/time when creating DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1616
diff
changeset
|
376 tag != DICOM_TAG_STUDY_TIME && |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
377 dicom.HasTag(tag)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
378 { |
2952
4ceb9bf7b00c
added details string in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2936
diff
changeset
|
379 throw OrthancException(ErrorCode_CreateDicomOverrideTag, name); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
380 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
381 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
382 if (tag == DICOM_TAG_PIXEL_DATA) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
383 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
384 throw OrthancException(ErrorCode_CreateDicomUseContent); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
385 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
386 else |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
387 { |
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
|
388 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
|
389 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
390 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
391 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
392 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
393 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
394 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
395 static void CreateSeries(RestApiPostCall& call, |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
396 ParsedDicomFile& base /* in */, |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
397 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
|
398 bool decodeBinaryTags, |
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
|
399 const std::string& privateCreator) |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
400 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
401 assert(content.isArray()); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
402 assert(content.size() > 0); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
403 ServerContext& context = OrthancRestApi::GetContext(call); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
404 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
405 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
|
406 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
|
407 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
408 std::string someInstance; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
409 |
1566 | 410 try |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
411 { |
1569 | 412 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
|
413 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
414 std::unique_ptr<ParsedDicomFile> dicom(base.Clone(false)); |
1566 | 415 const Json::Value* payload = NULL; |
416 | |
417 if (content[i].type() == Json::stringValue) | |
418 { | |
419 payload = &content[i]; | |
420 } | |
421 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
|
422 { |
1566 | 423 if (!content[i].isMember("Content")) |
424 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
425 throw OrthancException(ErrorCode_CreateDicomNoPayload); |
1566 | 426 } |
427 | |
428 payload = &content[i]["Content"]; | |
429 | |
1569 | 430 if (content[i].isMember("Tags")) |
1570 | 431 { |
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
|
432 InjectTags(*dicom, content[i]["Tags"], decodeBinaryTags, privateCreator); |
1570 | 433 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
434 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
435 |
1566 | 436 if (payload == NULL || |
437 payload->type() != Json::stringValue) | |
438 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
439 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); |
1566 | 440 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
441 |
1566 | 442 dicom->EmbedContent(payload->asString()); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
443 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
|
444 dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1)); |
1566 | 445 |
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
|
446 StoreCreatedInstance(someInstance, call, *dicom, false); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
447 } |
1566 | 448 } |
1616 | 449 catch (OrthancException&) |
1566 | 450 { |
1569 | 451 // Error: Remove the newly-created series |
452 | |
453 std::string series; | |
454 if (context.GetIndex().LookupParent(series, someInstance)) | |
1570 | 455 { |
1569 | 456 Json::Value dummy; |
457 context.GetIndex().DeleteResource(dummy, series, ResourceType_Series); | |
1570 | 458 } |
1569 | 459 |
1616 | 460 throw; |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
461 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
462 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
463 std::string series; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
464 if (context.GetIndex().LookupParent(series, someInstance)) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
465 { |
1569 | 466 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
|
467 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
468 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
469 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
470 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
471 static void CreateDicomV2(RestApiPostCall& call, |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
472 const Json::Value& request) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
473 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
474 assert(request.isObject()); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
475 ServerContext& context = OrthancRestApi::GetContext(call); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
476 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
477 if (!request.isMember("Tags") || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
478 request["Tags"].type() != Json::objectValue) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
479 { |
1569 | 480 throw OrthancException(ErrorCode_BadRequest); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
481 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
482 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1699
diff
changeset
|
483 ParsedDicomFile dicom(true); |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
484 |
1557 | 485 { |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
486 Encoding encoding; |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
487 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
488 if (request["Tags"].isMember("SpecificCharacterSet")) |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
489 { |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
490 const char* tmp = request["Tags"]["SpecificCharacterSet"].asCString(); |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
491 if (!GetDicomEncoding(encoding, tmp)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
492 { |
2955 | 493 throw OrthancException(ErrorCode_ParameterOutOfRange, |
494 "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
|
495 } |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
496 } |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
497 else |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
498 { |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2361
diff
changeset
|
499 encoding = GetDefaultDicomEncoding(); |
1565
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 dicom.SetEncoding(encoding); |
1557 | 503 } |
504 | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
505 ResourceType parentType = ResourceType_Instance; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
506 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
507 if (request.isMember("Parent")) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
508 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
509 // Locate the parent tags |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
510 std::string parent = request["Parent"].asString(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
511 if (!context.GetIndex().LookupResourceType(parentType, parent)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
512 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
513 throw OrthancException(ErrorCode_CreateDicomBadParent); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
514 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
515 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
516 if (parentType == ResourceType_Instance) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
517 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
518 throw OrthancException(ErrorCode_CreateDicomParentIsInstance); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
519 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
520 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
521 // 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
|
522 // retrieve all its tags |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
523 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
|
524 std::string siblingInstanceId; |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
525 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
526 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
527 // 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
|
528 std::list<std::string> siblingInstances; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
529 context.GetIndex().GetChildInstances(siblingInstances, parent); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
530 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
531 if (siblingInstances.empty()) |
1569 | 532 { |
533 // Error: No instance (should never happen) | |
534 throw OrthancException(ErrorCode_InternalError); | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
535 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
536 |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
537 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
|
538 context.ReadDicomAsJson(siblingTags, siblingInstanceId); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
539 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
540 |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
541 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
542 // 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
|
543 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
544 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
|
545 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
546 if (siblingTags.isMember(SPECIFIC_CHARACTER_SET)) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
547 { |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
548 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
|
549 |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
550 if (!siblingTags[SPECIFIC_CHARACTER_SET].isMember("Value") || |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
551 siblingTags[SPECIFIC_CHARACTER_SET]["Value"].type() != Json::stringValue || |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
552 !GetDicomEncoding(encoding, siblingTags[SPECIFIC_CHARACTER_SET]["Value"].asCString())) |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
553 { |
3009
750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
554 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
|
555 << "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
|
556 encoding = GetDefaultDicomEncoding(); |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
557 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
558 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
559 dicom.SetEncoding(encoding); |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
560 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
561 } |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
562 |
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
563 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
564 // 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
|
565 typedef std::set<DicomTag> ModuleTags; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
566 ModuleTags moduleTags; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
567 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
568 ResourceType type = parentType; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
569 for (;;) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
570 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
571 DicomTag::AddTagsForModule(moduleTags, GetModule(type)); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
572 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
573 if (type == ResourceType_Patient) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
574 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
575 break; // We're done |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
576 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
577 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
578 // Go up |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
579 std::string tmp; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
580 if (!context.GetIndex().LookupParent(tmp, parent)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
581 { |
1569 | 582 throw OrthancException(ErrorCode_InternalError); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
583 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
584 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
585 parent = tmp; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
586 type = GetParentResourceType(type); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
587 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
588 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
589 for (ModuleTags::const_iterator it = moduleTags.begin(); |
1616 | 590 it != moduleTags.end(); ++it) |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
591 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
592 std::string t = it->Format(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
593 if (siblingTags.isMember(t)) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
594 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
595 const Json::Value& tag = siblingTags[t]; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
596 if (tag["Type"] == "Null") |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
597 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
598 dicom.ReplacePlainString(*it, ""); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
599 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
600 else if (tag["Type"] == "String") |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
601 { |
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
|
602 std::string value = tag["Value"].asString(); // This is an UTF-8 value (as it comes from JSON) |
6cc72ebfd6ef
Fix issue #141 (/tools/create-dicom removes non-ASCII characters from study description)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
603 dicom.ReplacePlainString(*it, value); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
604 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
605 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
606 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
607 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
608 |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
609 |
1689 | 610 bool decodeBinaryTags = true; |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
611 if (request.isMember("InterpretBinaryTags")) |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
612 { |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
613 const Json::Value& v = request["InterpretBinaryTags"]; |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
614 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
|
615 { |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
616 throw OrthancException(ErrorCode_BadRequest); |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
617 } |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
618 |
1689 | 619 decodeBinaryTags = v.asBool(); |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
620 } |
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
621 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
622 |
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
|
623 // 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
|
624 std::string privateCreator; |
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
|
625 if (request.isMember("PrivateCreator")) |
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
|
626 { |
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
|
627 const Json::Value& v = request["PrivateCreator"]; |
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
|
628 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
|
629 { |
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
|
630 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
|
631 } |
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
|
632 |
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
|
633 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
|
634 } |
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
|
635 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
|
636 { |
1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
637 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
|
638 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
|
639 } |
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
|
640 |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
641 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
642 // Inject time-related information |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
643 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
|
644 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
|
645 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
|
646 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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
652 if (parentType == ResourceType_Patient || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
653 parentType == ResourceType_Study || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
654 parentType == ResourceType_Instance /* no parent */) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
655 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
656 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
|
657 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
|
658 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
659 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
660 if (parentType == ResourceType_Patient || |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
661 parentType == ResourceType_Instance /* no parent */) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
662 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
663 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
|
664 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
|
665 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
666 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
667 |
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
|
668 InjectTags(dicom, request["Tags"], decodeBinaryTags, privateCreator); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
669 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
670 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
671 // Inject the content (either an image, or a PDF file) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
672 if (request.isMember("Content")) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
673 { |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
674 const Json::Value& content = request["Content"]; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
675 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
676 if (content.type() == Json::stringValue) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
677 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
678 dicom.EmbedContent(request["Content"].asString()); |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
679 |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
680 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
681 else if (content.type() == Json::arrayValue) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
682 { |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
683 if (content.size() > 0) |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
684 { |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
685 // Let's create a series instead of a single instance |
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
|
686 CreateSeries(call, dicom, content, decodeBinaryTags, privateCreator); |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
687 return; |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
688 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
689 } |
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
690 else |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
691 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
692 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); |
1555
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 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
695 |
1564
1b7def486e62
creation of DICOM series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1562
diff
changeset
|
696 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
|
697 StoreCreatedInstance(id, call, dicom, true); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
698 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
699 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
700 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
701 static void CreateDicom(RestApiPostCall& call) |
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 Json::Value request; |
1569 | 704 if (!call.ParseJsonRequest(request) || |
705 !request.isObject()) | |
1570 | 706 { |
707 throw OrthancException(ErrorCode_BadRequest); | |
708 } | |
1569 | 709 |
710 if (request.isMember("Tags")) | |
1570 | 711 { |
712 CreateDicomV2(call, request); | |
713 } | |
1569 | 714 else |
1570 | 715 { |
716 // Compatibility with Orthanc <= 0.9.3 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1699
diff
changeset
|
717 ParsedDicomFile dicom(true); |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1570
diff
changeset
|
718 CreateDicomV1(dicom, call, request); |
1569 | 719 |
1570 | 720 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
|
721 StoreCreatedInstance(id, call, dicom, true); |
1570 | 722 } |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
723 } |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
724 |
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
725 |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
726 static void SplitStudy(RestApiPostCall& call) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
727 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
728 ServerContext& context = OrthancRestApi::GetContext(call); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
729 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
730 Json::Value request; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
731 if (!call.ParseJsonRequest(request)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
732 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
733 // Bad JSON request |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
734 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
735 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
736 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
737 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
|
738 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
739 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
|
740 job->SetOrigin(call); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
741 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
742 std::vector<std::string> series; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
743 SerializationToolbox::ReadArrayOfStrings(series, request, "Series"); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
744 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
745 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
|
746 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
747 job->AddSourceSeries(series[i]); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
748 } |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
749 |
2860 | 750 job->AddTrailingStep(); |
751 | |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
752 SetKeepSource(*job, request); |
2844
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
753 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
754 static const char* REMOVE = "Remove"; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
755 if (request.isMember(REMOVE)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
756 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
757 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
|
758 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
759 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
760 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
761 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
762 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
|
763 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
764 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
|
765 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
766 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
767 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
768 else |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
769 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
770 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
|
771 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
772 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
773 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
774 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
775 static const char* REPLACE = "Replace"; |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
776 if (request.isMember(REPLACE)) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
777 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
778 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
|
779 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
780 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
781 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
782 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
783 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
|
784 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
785 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
|
786 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
787 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
|
788 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
789 if (value.type() != Json::stringValue) |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
790 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
791 throw OrthancException(ErrorCode_BadFileFormat); |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
792 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
793 else |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
794 { |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
795 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
|
796 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
797 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
798 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
799 |
2869 | 800 OrthancRestApi::GetApi(call).SubmitCommandsJob |
801 (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
|
802 } |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
803 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
804 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
805 static void MergeStudy(RestApiPostCall& call) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
806 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
807 ServerContext& context = OrthancRestApi::GetContext(call); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
808 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
809 Json::Value request; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
810 if (!call.ParseJsonRequest(request)) |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
811 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
812 // Bad JSON request |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
813 throw OrthancException(ErrorCode_BadFileFormat); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
814 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
815 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
816 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
|
817 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3709
diff
changeset
|
818 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
|
819 job->SetOrigin(call); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
820 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
821 std::vector<std::string> resources; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
822 SerializationToolbox::ReadArrayOfStrings(resources, request, "Resources"); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
823 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
824 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
|
825 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
826 job->AddSource(resources[i]); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
827 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
828 |
2860 | 829 job->AddTrailingStep(); |
830 | |
3942
5b882ad2ffd0
"/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3930
diff
changeset
|
831 SetKeepSource(*job, request); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
832 |
2869 | 833 OrthancRestApi::GetApi(call).SubmitCommandsJob |
834 (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
|
835 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
836 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2844
diff
changeset
|
837 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
838 void OrthancRestApi::RegisterAnonymizeModify() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
839 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
840 Register("/instances/{id}/modify", ModifyInstance); |
2639 | 841 Register("/series/{id}/modify", ModifyResource<ResourceType_Series>); |
842 Register("/studies/{id}/modify", ModifyResource<ResourceType_Study>); | |
843 Register("/patients/{id}/modify", ModifyResource<ResourceType_Patient>); | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
844 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 Register("/instances/{id}/anonymize", AnonymizeInstance); |
2639 | 846 Register("/series/{id}/anonymize", AnonymizeResource<ResourceType_Series>); |
847 Register("/studies/{id}/anonymize", AnonymizeResource<ResourceType_Study>); | |
848 Register("/patients/{id}/anonymize", AnonymizeResource<ResourceType_Patient>); | |
796
e7b1ca0f1e04
creation of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
795
diff
changeset
|
849 |
1120
009dce4ea2f6
/tools/create-dicom now accepts PatientID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1010
diff
changeset
|
850 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
|
851 |
99863d6245b2
New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2825
diff
changeset
|
852 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
|
853 Register("/studies/{id}/merge", MergeStudy); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
854 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 } |