Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.cpp @ 5011:c014ab79fca5
fixed /move documentation + improved error reporting
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 31 May 2022 09:36:00 +0200 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
rev | line source |
---|---|
0 | 1 /** |
62 | 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:
831
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
11 * the License, or (at your option) any later version. |
136 | 12 * |
0 | 13 * This program is distributed in the hope that it will be useful, but |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
16 * Lesser General Public License for more details. |
0 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
0 | 21 **/ |
22 | |
23 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
24 #include "../PrecompiledHeaders.h" |
0 | 25 #include "DicomFindAnswers.h" |
26 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
27 #include "../DicomParsing/FromDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
28 #include "../OrthancException.h" |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
29 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
30 #include <memory> |
1789 | 31 #include <dcmtk/dcmdata/dcfilefo.h> |
1847 | 32 #include <boost/noncopyable.hpp> |
1789 | 33 |
0 | 34 |
62 | 35 namespace Orthanc |
0 | 36 { |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
37 void DicomFindAnswers::AddAnswerInternal(ParsedDicomFile* answer) |
1789 | 38 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
39 std::unique_ptr<ParsedDicomFile> protection(answer); |
1797
23722a191e4e
worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
40 |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
41 if (isWorklist_) |
1797
23722a191e4e
worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
42 { |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
43 // These lines are necessary when serving worklists, otherwise |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
44 // Orthanc does not behave as "wlmscpfs" |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
45 protection->Remove(DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
46 protection->Remove(DICOM_TAG_SOP_INSTANCE_UID); |
1789 | 47 } |
48 | |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
49 protection->ChangeEncoding(encoding_); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
50 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
51 answers_.push_back(protection.release()); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
52 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
53 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
54 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
55 DicomFindAnswers::DicomFindAnswers(bool isWorklist) : |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
56 encoding_(GetDefaultDicomEncoding()), |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
57 isWorklist_(isWorklist), |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
58 complete_(true) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
59 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
60 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
61 |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
62 DicomFindAnswers::~DicomFindAnswers() |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
63 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
64 Clear(); |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
65 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
66 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
67 Encoding DicomFindAnswers::GetEncoding() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
68 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
69 return encoding_; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
70 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
71 |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
72 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
73 void DicomFindAnswers::SetEncoding(Encoding encoding) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
74 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
75 for (size_t i = 0; i < answers_.size(); i++) |
1789 | 76 { |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
77 assert(answers_[i] != NULL); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
78 answers_[i]->ChangeEncoding(encoding); |
1789 | 79 } |
80 | |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
81 encoding_ = encoding; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
82 } |
1789 | 83 |
84 | |
2059 | 85 void DicomFindAnswers::SetWorklist(bool isWorklist) |
86 { | |
87 if (answers_.empty()) | |
88 { | |
89 isWorklist_ = isWorklist; | |
90 } | |
91 else | |
92 { | |
93 // This set of answers is not empty anymore, cannot change its type | |
94 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
95 } | |
96 } | |
97 | |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
98 bool DicomFindAnswers::IsWorklist() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
99 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
100 return isWorklist_; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
101 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
102 |
2059 | 103 |
0 | 104 void DicomFindAnswers::Clear() |
105 { | |
1789 | 106 for (size_t i = 0; i < answers_.size(); i++) |
0 | 107 { |
1789 | 108 assert(answers_[i] != NULL); |
109 delete answers_[i]; | |
0 | 110 } |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
111 |
1789 | 112 answers_.clear(); |
0 | 113 } |
114 | |
1789 | 115 |
0 | 116 void DicomFindAnswers::Reserve(size_t size) |
117 { | |
1789 | 118 if (size > answers_.size()) |
0 | 119 { |
1789 | 120 answers_.reserve(size); |
0 | 121 } |
122 } | |
123 | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
124 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
125 void DicomFindAnswers::Add(const DicomMap& map) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
126 { |
3276
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3158
diff
changeset
|
127 // We use the permissive mode to be tolerant wrt. invalid DICOM |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3158
diff
changeset
|
128 // files that contain some tags with out-of-range values (such |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3158
diff
changeset
|
129 // tags are removed from the answers) |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
130 AddAnswerInternal(new ParsedDicomFile(map, encoding_, true /* permissive */)); |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
131 //"" /* no private creator */)); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
132 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
133 |
1789 | 134 |
4204 | 135 void DicomFindAnswers::Add(const ParsedDicomFile& dicom) |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
136 { |
2521
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
137 AddAnswerInternal(dicom.Clone(true)); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
138 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
139 |
1995
f0acfa753973
New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
140 void DicomFindAnswers::Add(const void* dicom, |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
141 size_t size) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
142 { |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
143 AddAnswerInternal(new ParsedDicomFile(dicom, size)); |
1789 | 144 } |
145 | |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
146 size_t DicomFindAnswers::GetSize() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
147 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
148 return answers_.size(); |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
149 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
150 |
1789 | 151 |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
152 ParsedDicomFile& DicomFindAnswers::GetAnswer(size_t index) const |
1789 | 153 { |
154 if (index < answers_.size()) | |
155 { | |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
156 return *answers_[index]; |
1789 | 157 } |
158 else | |
159 { | |
160 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
161 } | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
162 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
163 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
164 |
1789 | 165 DcmDataset* DicomFindAnswers::ExtractDcmDataset(size_t index) const |
166 { | |
3158
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
167 // As "DicomFindAnswers" stores its content using class |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
168 // "ParsedDicomFile" (that internally uses "DcmFileFormat" from |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
169 // DCMTK), the dataset can contain tags that are reserved if |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
170 // storing the media on the disk, notably tag |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
171 // "MediaStorageSOPClassUID" (0002,0002). In this function, we |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
172 // remove all those tags whose group is below 0x0008. The |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
173 // resulting data set is clean for emission in the C-FIND SCP. |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
174 |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
175 // http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#sect_C.4.1.1.3 |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
176 // https://groups.google.com/d/msg/orthanc-users/D3kpPuX8yV0/_zgHOzkMEQAJ |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
177 |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
178 DcmDataset& source = *GetAnswer(index).GetDcmtkObject().getDataset(); |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
179 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
180 std::unique_ptr<DcmDataset> target(new DcmDataset); |
3158
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
181 |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
182 for (unsigned long i = 0; i < source.card(); i++) |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
183 { |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
184 const DcmElement* element = source.getElement(i); |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
185 assert(element != NULL); |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
186 |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
187 if (element != NULL && |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
188 element->getTag().getGroup() >= 0x0008 && |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
189 element->getTag().getElement() != 0x0000) |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
190 { |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
191 target->insert(dynamic_cast<DcmElement*>(element->clone())); |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
192 } |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
193 } |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
194 |
b6e7714c3fe6
Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
195 return target.release(); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
196 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
197 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
198 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
199 void DicomFindAnswers::ToJson(Json::Value& target, |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
200 size_t index, |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
201 DicomToJsonFormat format) const |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
202 { |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
203 const ParsedDicomFile& answer = GetAnswer(index); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
204 answer.DatasetToJson(target, format, DicomToJsonFlags_None, 0); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
205 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
206 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
207 |
1368 | 208 void DicomFindAnswers::ToJson(Json::Value& target, |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
209 DicomToJsonFormat format) const |
0 | 210 { |
211 target = Json::arrayValue; | |
212 | |
213 for (size_t i = 0; i < GetSize(); i++) | |
214 { | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
215 Json::Value answer; |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
216 ToJson(answer, i, format); |
0 | 217 target.append(answer); |
218 } | |
219 } | |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
220 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
221 |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
222 bool DicomFindAnswers::IsComplete() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
223 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
224 return complete_; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
225 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
226 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
227 void DicomFindAnswers::SetComplete(bool isComplete) |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
228 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
229 complete_ = isComplete; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
230 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
231 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
232 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
233 #if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
234 void DicomFindAnswers::Add(ParsedDicomFile& dicom) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
235 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
236 return Add(const_cast<const ParsedDicomFile&>(dicom)); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
237 } |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
238 |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
239 void DicomFindAnswers::ToJson(Json::Value& target, |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
240 size_t index, |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
241 bool simplify) const |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
242 { |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
243 DicomToJsonFormat format = (simplify ? DicomToJsonFormat_Human : DicomToJsonFormat_Full); |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
244 ToJson(target, index, format); |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
245 } |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
246 |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
247 |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
248 void DicomFindAnswers::ToJson(Json::Value& target, |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
249 bool simplify) const |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
250 { |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
251 DicomToJsonFormat format = (simplify ? DicomToJsonFormat_Human : DicomToJsonFormat_Full); |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
252 ToJson(target, format); |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
253 } |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
254 #endif |
0 | 255 } |