comparison OrthancServer/Sources/Database/FindRequest.cpp @ 5596:81a29ad7fb4b find-refactoring

added possibility to retrieve main DICOM tags and metadata at any level
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 May 2024 18:44:53 +0200
parents a87f2a56257d
children 4690a0d2b01e
comparison
equal deleted inserted replaced
5595:a87f2a56257d 5596:81a29ad7fb4b
32 FindRequest::FindRequest(ResourceType level) : 32 FindRequest::FindRequest(ResourceType level) :
33 level_(level), 33 level_(level),
34 hasLimits_(false), 34 hasLimits_(false),
35 limitsSince_(0), 35 limitsSince_(0),
36 limitsCount_(0), 36 limitsCount_(0),
37 retrieveMainDicomTags_(false), 37 retrieveMainDicomTagsPatients_(false),
38 retrieveMetadata_(false), 38 retrieveMainDicomTagsStudies_(false),
39 retrieveMainDicomTagsSeries_(false),
40 retrieveMainDicomTagsInstances_(false),
41 retrieveMetadataPatients_(false),
42 retrieveMetadataStudies_(false),
43 retrieveMetadataSeries_(false),
44 retrieveMetadataInstances_(false),
39 retrieveLabels_(false), 45 retrieveLabels_(false),
40 retrieveAttachments_(false), 46 retrieveAttachments_(false),
41 retrieveParentIdentifier_(false), 47 retrieveParentIdentifier_(false),
42 retrieveChildrenIdentifiers_(false) 48 retrieveChildrenIdentifiers_(false)
43 { 49 {
126 { 132 {
127 ordering_.push_back(new Ordering(Key(metadataType), direction)); 133 ordering_.push_back(new Ordering(Key(metadataType), direction));
128 } 134 }
129 135
130 136
137 void FindRequest::SetRetrieveMainDicomTags(ResourceType level,
138 bool retrieve)
139 {
140 if (!IsResourceLevelAboveOrEqual(level, level_))
141 {
142 throw OrthancException(ErrorCode_ParameterOutOfRange);
143 }
144
145 switch (level)
146 {
147 case ResourceType_Patient:
148 retrieveMainDicomTagsPatients_ = retrieve;
149 break;
150
151 case ResourceType_Study:
152 retrieveMainDicomTagsStudies_ = retrieve;
153 break;
154
155 case ResourceType_Series:
156 retrieveMainDicomTagsSeries_ = retrieve;
157 break;
158
159 case ResourceType_Instance:
160 retrieveMainDicomTagsInstances_ = retrieve;
161 break;
162
163 default:
164 throw OrthancException(ErrorCode_InternalError);
165 }
166 }
167
168
169 bool FindRequest::IsRetrieveMainDicomTags(ResourceType level) const
170 {
171 if (!IsResourceLevelAboveOrEqual(level, level_))
172 {
173 throw OrthancException(ErrorCode_ParameterOutOfRange);
174 }
175
176 switch (level)
177 {
178 case ResourceType_Patient:
179 return retrieveMainDicomTagsPatients_;
180
181 case ResourceType_Study:
182 return retrieveMainDicomTagsStudies_;
183
184 case ResourceType_Series:
185 return retrieveMainDicomTagsSeries_;
186
187 case ResourceType_Instance:
188 return retrieveMainDicomTagsInstances_;
189
190 default:
191 throw OrthancException(ErrorCode_InternalError);
192 }
193 }
194
195
196 void FindRequest::SetRetrieveMetadata(ResourceType level,
197 bool retrieve)
198 {
199 if (!IsResourceLevelAboveOrEqual(level, level_))
200 {
201 throw OrthancException(ErrorCode_ParameterOutOfRange);
202 }
203
204 switch (level)
205 {
206 case ResourceType_Patient:
207 retrieveMetadataPatients_ = retrieve;
208 break;
209
210 case ResourceType_Study:
211 retrieveMetadataStudies_ = retrieve;
212 break;
213
214 case ResourceType_Series:
215 retrieveMetadataSeries_ = retrieve;
216 break;
217
218 case ResourceType_Instance:
219 retrieveMetadataInstances_ = retrieve;
220 break;
221
222 default:
223 throw OrthancException(ErrorCode_InternalError);
224 }
225 }
226
227
228 bool FindRequest::IsRetrieveMetadata(ResourceType level) const
229 {
230 if (!IsResourceLevelAboveOrEqual(level, level_))
231 {
232 throw OrthancException(ErrorCode_ParameterOutOfRange);
233 }
234
235 switch (level)
236 {
237 case ResourceType_Patient:
238 return retrieveMetadataPatients_;
239
240 case ResourceType_Study:
241 return retrieveMetadataStudies_;
242
243 case ResourceType_Series:
244 return retrieveMetadataSeries_;
245
246 case ResourceType_Instance:
247 return retrieveMetadataInstances_;
248
249 default:
250 throw OrthancException(ErrorCode_InternalError);
251 }
252 }
253
254
131 void FindRequest::SetRetrieveParentIdentifier(bool retrieve) 255 void FindRequest::SetRetrieveParentIdentifier(bool retrieve)
132 { 256 {
133 if (level_ == ResourceType_Patient) 257 if (level_ == ResourceType_Patient)
134 { 258 {
135 throw OrthancException(ErrorCode_BadParameterType); 259 throw OrthancException(ErrorCode_BadParameterType);
156 280
157 void FindRequest::AddRetrieveChildrenMetadata(MetadataType metadata) 281 void FindRequest::AddRetrieveChildrenMetadata(MetadataType metadata)
158 { 282 {
159 if (IsRetrieveChildrenMetadata(metadata)) 283 if (IsRetrieveChildrenMetadata(metadata))
160 { 284 {
161 throw OrthancException(ErrorCode_BadParameterType); 285 throw OrthancException(ErrorCode_BadSequenceOfCalls);
162 } 286 }
163 else 287 else
164 { 288 {
165 retrieveChildrenMetadata_.insert(metadata); 289 retrieveChildrenMetadata_.insert(metadata);
166 } 290 }
167 } 291 }
292
293
294 void FindRequest::AddRetrieveAttachmentOfOneInstance(FileContentType type)
295 {
296 if (retrieveAttachmentOfOneInstance_.find(type) == retrieveAttachmentOfOneInstance_.end())
297 {
298 retrieveAttachmentOfOneInstance_.insert(type);
299 }
300 else
301 {
302 throw OrthancException(ErrorCode_BadSequenceOfCalls);
303 }
304 }
168 } 305 }