Mercurial > hg > orthanc
annotate OrthancServer/Search/LookupIdentifierQuery.h @ 3108:55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Jan 2019 21:23:31 +0100 |
parents | 4e43e67f8ecf |
children |
rev | line source |
---|---|
1745 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1745 | 4 * Department, University Hospital of Liege, Belgium |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
1745 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
1747 | 36 #include "../IDatabaseWrapper.h" |
1745 | 37 |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
38 #include "SetOfResources.h" |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
39 |
1745 | 40 #include <vector> |
41 #include <boost/noncopyable.hpp> | |
42 | |
43 namespace Orthanc | |
44 { | |
45 /** | |
46 * Primitive for wildcard matching, as defined in DICOM: | |
47 * http://dicom.nema.org/dicom/2013/output/chtml/part04/sect_C.2.html#sect_C.2.2.2.4 | |
48 * | |
49 * "Any occurrence of an "*" or a "?", then "*" shall match any | |
50 * sequence of characters (including a zero length value) and "?" | |
51 * shall match any single character. This matching is case | |
52 * sensitive, except for Attributes with an PN Value | |
53 * Representation (e.g., Patient Name (0010,0010))." | |
54 * | |
55 * Pay attention to the fact that "*" (resp. "?") generally | |
56 * corresponds to "%" (resp. "_") in primitive LIKE of SQL. The | |
57 * values "%", "_", "\" should in the user request should | |
58 * respectively be escaped as "\%", "\_" and "\\". | |
1746 | 59 * |
1745 | 60 * This matching must be case sensitive: The special case of PN VR |
61 * is taken into consideration by normalizing the query string in | |
62 * method "NormalizeIdentifier()". | |
63 **/ | |
64 | |
65 class LookupIdentifierQuery : public boost::noncopyable | |
66 { | |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
67 // This class encodes a conjunction ("AND") of disjunctions. Each |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
68 // disjunction represents an "OR" of several constraints. |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
69 |
1748 | 70 public: |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
71 class SingleConstraint |
1745 | 72 { |
1748 | 73 private: |
1745 | 74 DicomTag tag_; |
75 IdentifierConstraintType type_; | |
76 std::string value_; | |
77 | |
1748 | 78 public: |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
79 SingleConstraint(const DicomTag& tag, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
80 IdentifierConstraintType type, |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
81 const std::string& value); |
1748 | 82 |
83 const DicomTag& GetTag() const | |
84 { | |
85 return tag_; | |
86 } | |
87 | |
88 IdentifierConstraintType GetType() const | |
89 { | |
90 return type_; | |
91 } | |
92 | |
93 const std::string& GetValue() const | |
94 { | |
95 return value_; | |
96 } | |
1745 | 97 }; |
98 | |
1748 | 99 |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
100 class RangeConstraint |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
101 { |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
102 private: |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
103 DicomTag tag_; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
104 std::string start_; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
105 std::string end_; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
106 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
107 public: |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
108 RangeConstraint(const DicomTag& tag, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
109 const std::string& start, |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
110 const std::string& end); |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
111 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
112 const DicomTag& GetTag() const |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
113 { |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
114 return tag_; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
115 } |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
116 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
117 const std::string& GetStart() const |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
118 { |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
119 return start_; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
120 } |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
121 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
122 const std::string& GetEnd() const |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
123 { |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
124 return end_; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
125 } |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
126 }; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
127 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
128 |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
129 class Disjunction : public boost::noncopyable |
1748 | 130 { |
131 private: | |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
132 std::vector<SingleConstraint*> singleConstraints_; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
133 std::vector<RangeConstraint*> rangeConstraints_; |
1748 | 134 |
135 public: | |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
136 ~Disjunction(); |
1748 | 137 |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
138 void Add(const DicomTag& tag, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
139 IdentifierConstraintType type, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
140 const std::string& value); |
1748 | 141 |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
142 void AddRange(const DicomTag& tag, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
143 const std::string& start, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
144 const std::string& end); |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
145 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
146 size_t GetSingleConstraintsCount() const |
1748 | 147 { |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
148 return singleConstraints_.size(); |
1748 | 149 } |
150 | |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
151 const SingleConstraint& GetSingleConstraint(size_t i) const |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
152 { |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
153 return *singleConstraints_[i]; |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
154 } |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
155 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
156 size_t GetRangeConstraintsCount() const |
1748 | 157 { |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
158 return rangeConstraints_.size(); |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
159 } |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
160 |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
161 const RangeConstraint& GetRangeConstraint(size_t i) const |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
162 { |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
163 return *rangeConstraints_[i]; |
1748 | 164 } |
165 }; | |
166 | |
167 | |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
168 private: |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
169 typedef std::vector<Disjunction*> Disjunctions; |
1745 | 170 |
171 ResourceType level_; | |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
172 Disjunctions disjunctions_; |
1745 | 173 |
174 public: | |
175 LookupIdentifierQuery(ResourceType level) : level_(level) | |
176 { | |
177 } | |
178 | |
179 ~LookupIdentifierQuery(); | |
180 | |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
181 bool IsIdentifier(const DicomTag& tag); |
1745 | 182 |
183 void AddConstraint(DicomTag tag, | |
184 IdentifierConstraintType type, | |
185 const std::string& value); | |
186 | |
2697
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
187 void AddRange(DicomTag tag, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
188 const std::string& start, |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
189 const std::string& end); |
e583478e0c6c
New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2696
diff
changeset
|
190 |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
191 Disjunction& AddDisjunction(); |
1748 | 192 |
1746 | 193 ResourceType GetLevel() const |
194 { | |
195 return level_; | |
196 } | |
197 | |
1748 | 198 // The database must be locked |
199 void Apply(std::list<std::string>& result, | |
200 IDatabaseWrapper& database); | |
1745 | 201 |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
202 void Apply(SetOfResources& result, |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
203 IDatabaseWrapper& database); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
204 |
1758 | 205 void Print(std::ostream& s) const; |
1745 | 206 }; |
207 } |