Mercurial > hg > orthanc
annotate OrthancServer/Search/LookupIdentifierQuery.cpp @ 2200:af60b784d2b8
Ignore "Group Length" tags in C-FIND queries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Dec 2016 14:40:34 +0100 |
parents | 7e8889bc95c6 |
children | a3a65de1840f |
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 |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
1747 | 33 #include "../PrecompiledHeadersServer.h" |
1745 | 34 #include "LookupIdentifierQuery.h" |
35 | |
1747 | 36 #include "../../Core/OrthancException.h" |
1746 | 37 #include "SetOfResources.h" |
1758 | 38 #include "../FromDcmtkBridge.h" |
1745 | 39 |
40 #include <cassert> | |
41 | |
42 | |
43 | |
44 namespace Orthanc | |
45 { | |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
46 LookupIdentifierQuery::Disjunction::~Disjunction() |
1748 | 47 { |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
48 for (size_t i = 0; i < disjunction_.size(); i++) |
1748 | 49 { |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
50 delete disjunction_[i]; |
1748 | 51 } |
52 } | |
53 | |
54 | |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
55 void LookupIdentifierQuery::Disjunction::Add(const DicomTag& tag, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
56 IdentifierConstraintType type, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
57 const std::string& value) |
1748 | 58 { |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
59 disjunction_.push_back(new Constraint(tag, type, value)); |
1748 | 60 } |
61 | |
1746 | 62 |
63 LookupIdentifierQuery::~LookupIdentifierQuery() | |
64 { | |
65 for (Constraints::iterator it = constraints_.begin(); | |
66 it != constraints_.end(); ++it) | |
67 { | |
68 delete *it; | |
69 } | |
70 } | |
71 | |
72 | |
1745 | 73 void LookupIdentifierQuery::AddConstraint(DicomTag tag, |
74 IdentifierConstraintType type, | |
75 const std::string& value) | |
76 { | |
77 assert(IsIdentifier(tag)); | |
1751
fb569ee09a69
LookupResource complete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1750
diff
changeset
|
78 constraints_.push_back(new Disjunction); |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
79 constraints_.back()->Add(tag, type, value); |
1745 | 80 } |
81 | |
82 | |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
83 LookupIdentifierQuery::Disjunction& LookupIdentifierQuery::AddDisjunction() |
1745 | 84 { |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
85 constraints_.push_back(new Disjunction); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1748
diff
changeset
|
86 return *constraints_.back(); |
1745 | 87 } |
88 | |
89 | |
1746 | 90 void LookupIdentifierQuery::Apply(std::list<std::string>& result, |
91 IDatabaseWrapper& database) | |
92 { | |
93 SetOfResources resources(database, level_); | |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
94 Apply(resources, database); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
95 |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
96 resources.Flatten(result); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
97 } |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
98 |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
99 |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
100 void LookupIdentifierQuery::Apply(SetOfResources& result, |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
101 IDatabaseWrapper& database) |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
102 { |
1746 | 103 for (size_t i = 0; i < GetSize(); i++) |
104 { | |
1748 | 105 std::list<int64_t> a; |
106 | |
107 for (size_t j = 0; j < constraints_[i]->GetSize(); j++) | |
108 { | |
109 const Constraint& constraint = constraints_[i]->GetConstraint(j); | |
110 std::list<int64_t> b; | |
111 database.LookupIdentifier(b, level_, constraint.GetTag(), constraint.GetType(), constraint.GetValue()); | |
112 | |
113 a.splice(a.end(), b); | |
114 } | |
115 | |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
116 result.Intersect(a); |
1746 | 117 } |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
118 } |
1746 | 119 |
1758 | 120 |
121 void LookupIdentifierQuery::Print(std::ostream& s) const | |
122 { | |
123 s << "Constraint: " << std::endl; | |
124 for (Constraints::const_iterator | |
125 it = constraints_.begin(); it != constraints_.end(); ++it) | |
126 { | |
127 if (it == constraints_.begin()) | |
128 s << " "; | |
129 else | |
130 s << "OR "; | |
131 | |
132 for (size_t j = 0; j < (*it)->GetSize(); j++) | |
133 { | |
134 const Constraint& c = (*it)->GetConstraint(j); | |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
135 s << FromDcmtkBridge::GetTagName(c.GetTag(), ""); |
1758 | 136 |
137 switch (c.GetType()) | |
138 { | |
139 case IdentifierConstraintType_Equal: s << " == "; break; | |
140 case IdentifierConstraintType_SmallerOrEqual: s << " <= "; break; | |
141 case IdentifierConstraintType_GreaterOrEqual: s << " >= "; break; | |
142 case IdentifierConstraintType_Wildcard: s << " ~= "; break; | |
143 default: | |
144 s << " ? "; | |
145 } | |
146 | |
147 s << c.GetValue() << std::endl; | |
148 } | |
149 } | |
150 } | |
1745 | 151 } |