Mercurial > hg > orthanc
comparison OrthancServer/Sources/Search/DatabaseLookup.cpp @ 4196:37310bb1cd30
Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 16 Sep 2020 13:22:30 +0200 |
parents | 05b8fd21089c |
children | 50b0c69b653a |
comparison
equal
deleted
inserted
replaced
4194:2bc49197f806 | 4196:37310bb1cd30 |
---|---|
64 return *constraints_[index]; | 64 return *constraints_[index]; |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 void DatabaseLookup::AddConstraint(DicomTagConstraint* constraint) | 69 void DatabaseLookup::AddConstraintInternal(DicomTagConstraint* constraint) |
70 { | 70 { |
71 if (constraint == NULL) | 71 if (constraint == NULL) |
72 { | 72 { |
73 throw OrthancException(ErrorCode_NullPointer); | 73 throw OrthancException(ErrorCode_NullPointer); |
74 } | 74 } |
161 std::string lower = dicomQuery.substr(0, separator); | 161 std::string lower = dicomQuery.substr(0, separator); |
162 std::string upper = dicomQuery.substr(separator + 1); | 162 std::string upper = dicomQuery.substr(separator + 1); |
163 | 163 |
164 if (!lower.empty()) | 164 if (!lower.empty()) |
165 { | 165 { |
166 AddConstraint(new DicomTagConstraint | 166 AddConstraintInternal(new DicomTagConstraint |
167 (tag, ConstraintType_GreaterOrEqual, lower, caseSensitive, mandatoryTag)); | 167 (tag, ConstraintType_GreaterOrEqual, lower, caseSensitive, mandatoryTag)); |
168 } | 168 } |
169 | 169 |
170 if (!upper.empty()) | 170 if (!upper.empty()) |
171 { | 171 { |
172 AddConstraint(new DicomTagConstraint | 172 AddConstraintInternal(new DicomTagConstraint |
173 (tag, ConstraintType_SmallerOrEqual, upper, caseSensitive, mandatoryTag)); | 173 (tag, ConstraintType_SmallerOrEqual, upper, caseSensitive, mandatoryTag)); |
174 } | 174 } |
175 } | 175 } |
176 else if (tag == DICOM_TAG_MODALITIES_IN_STUDY || | 176 else if (dicomQuery.find('\\') != std::string::npos) |
177 dicomQuery.find('\\') != std::string::npos) | |
178 { | 177 { |
179 DicomTag fixedTag(tag); | 178 DicomTag fixedTag(tag); |
180 | |
181 if (tag == DICOM_TAG_MODALITIES_IN_STUDY) | |
182 { | |
183 // http://www.itk.org/Wiki/DICOM_QueryRetrieve_Explained | |
184 // http://dicomiseasy.blogspot.be/2012/01/dicom-queryretrieve-part-i.html | |
185 fixedTag = DICOM_TAG_MODALITY; | |
186 } | |
187 | 179 |
188 std::unique_ptr<DicomTagConstraint> constraint | 180 std::unique_ptr<DicomTagConstraint> constraint |
189 (new DicomTagConstraint(fixedTag, ConstraintType_List, caseSensitive, mandatoryTag)); | 181 (new DicomTagConstraint(fixedTag, ConstraintType_List, caseSensitive, mandatoryTag)); |
190 | 182 |
191 std::vector<std::string> items; | 183 std::vector<std::string> items; |
194 for (size_t i = 0; i < items.size(); i++) | 186 for (size_t i = 0; i < items.size(); i++) |
195 { | 187 { |
196 constraint->AddValue(items[i]); | 188 constraint->AddValue(items[i]); |
197 } | 189 } |
198 | 190 |
199 AddConstraint(constraint.release()); | 191 AddConstraintInternal(constraint.release()); |
200 } | 192 } |
201 else if ( | 193 else if ( |
202 /** | 194 /** |
203 * New test in Orthanc 1.6.0: Wild card matching is only allowed | 195 * New test in Orthanc 1.6.0: Wild card matching is only allowed |
204 * for a subset of value representations: AE, CS, LO, LT, PN, | 196 * for a subset of value representations: AE, CS, LO, LT, PN, |
217 vr == ValueRepresentation_UnlimitedText // UT | 209 vr == ValueRepresentation_UnlimitedText // UT |
218 ) && | 210 ) && |
219 (dicomQuery.find('*') != std::string::npos || | 211 (dicomQuery.find('*') != std::string::npos || |
220 dicomQuery.find('?') != std::string::npos)) | 212 dicomQuery.find('?') != std::string::npos)) |
221 { | 213 { |
222 AddConstraint(new DicomTagConstraint | 214 AddConstraintInternal(new DicomTagConstraint |
223 (tag, ConstraintType_Wildcard, dicomQuery, caseSensitive, mandatoryTag)); | 215 (tag, ConstraintType_Wildcard, dicomQuery, caseSensitive, mandatoryTag)); |
224 } | 216 } |
225 else | 217 else |
226 { | 218 { |
227 AddConstraint(new DicomTagConstraint | 219 AddConstraintInternal(new DicomTagConstraint |
228 (tag, ConstraintType_Equal, dicomQuery, caseSensitive, mandatoryTag)); | 220 (tag, ConstraintType_Equal, dicomQuery, caseSensitive, mandatoryTag)); |
229 } | 221 } |
230 } | 222 } |
231 | 223 |
232 | 224 |
233 void DatabaseLookup::AddDicomConstraint(const DicomTag& tag, | 225 void DatabaseLookup::AddDicomConstraint(const DicomTag& tag, |
311 } | 303 } |
312 } | 304 } |
313 | 305 |
314 return true; | 306 return true; |
315 } | 307 } |
308 | |
309 | |
310 std::string DatabaseLookup::Format() const | |
311 { | |
312 std::string s; | |
313 | |
314 for (size_t i = 0; i < constraints_.size(); i++) | |
315 { | |
316 assert(constraints_[i] != NULL); | |
317 s += ("Contraint " + boost::lexical_cast<std::string>(i) + ": " + | |
318 constraints_[i]->Format() + "\n"); | |
319 } | |
320 | |
321 return s; | |
322 } | |
323 | |
324 | |
325 bool DatabaseLookup::HasTag(const DicomTag& tag) const | |
326 { | |
327 for (size_t i = 0; i < constraints_.size(); i++) | |
328 { | |
329 assert(constraints_[i] != NULL); | |
330 if (constraints_[i]->GetTag() == tag) | |
331 { | |
332 return true; | |
333 } | |
334 } | |
335 | |
336 return false; | |
337 } | |
316 } | 338 } |