annotate OrthancServer/Sources/Search/DatabaseLookup.cpp @ 4870:43e613a7756b

upgrade to year 2022
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Jan 2022 11:15:42 +0100
parents 7053502fbf97
children 6eff25f70121
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
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
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * In addition, as a special exception, the copyright holders of this
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * program give permission to link the code of its release with the
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * that use the same license as the "OpenSSL" library), and distribute
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * the linked executables. You must obey the GNU General Public License
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * in all respects for all of the code used other than "OpenSSL". If you
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * modify file(s) with this exception, you may extend this exception to
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * your version of the file(s), but you are not obligated to do so. If
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * you do not wish to do so, delete this exception statement from your
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * version. If you delete this exception statement from all source files
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * in the program, then also delete it here.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * This program is distributed in the hope that it will be useful, but
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * WITHOUT ANY WARRANTY; without even the implied warranty of
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * General Public License for more details.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * You should have received a copy of the GNU General Public License
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 **/
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "../PrecompiledHeadersServer.h"
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "DatabaseLookup.h"
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../ServerToolbox.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
39 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
40 #include "../../../OrthancFramework/Sources/DicomParsing/ToDcmtkBridge.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
41 #include "../../../OrthancFramework/Sources/OrthancException.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
42 #include "../../../OrthancFramework/Sources/Toolbox.h"
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
4304
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4196
diff changeset
44 #include <boost/lexical_cast.hpp>
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4196
diff changeset
45
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4196
diff changeset
46
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 namespace Orthanc
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 DatabaseLookup::~DatabaseLookup()
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 for (size_t i = 0; i < constraints_.size(); i++)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 assert(constraints_[i] != NULL);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 delete constraints_[i];
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 const DicomTagConstraint& DatabaseLookup::GetConstraint(size_t index) const
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 if (index >= constraints_.size())
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 throw OrthancException(ErrorCode_ParameterOutOfRange);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 else
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 assert(constraints_[index] != NULL);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 return *constraints_[index];
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
73 void DatabaseLookup::AddConstraintInternal(DicomTagConstraint* constraint)
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 if (constraint == NULL)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 throw OrthancException(ErrorCode_NullPointer);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 else
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 constraints_.push_back(constraint);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
86 bool DatabaseLookup::IsMatch(const DicomMap& value) const
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 for (size_t i = 0; i < constraints_.size(); i++)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 assert(constraints_[i] != NULL);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 if (!constraints_[i]->IsMatch(value))
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return false;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 return true;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
101 bool DatabaseLookup::IsMatch(DcmItem& item,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3182
diff changeset
102 Encoding encoding,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3182
diff changeset
103 bool hasCodeExtensions) const
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
104 {
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
105 for (size_t i = 0; i < constraints_.size(); i++)
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
106 {
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
107 assert(constraints_[i] != NULL);
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
108
3072
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
109 const bool isOptionalConstraint = !constraints_[i]->IsMandatory();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
110 const DcmTagKey tag = ToDcmtkBridge::Convert(constraints_[i]->GetTag());
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
111
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
112 DcmElement* element = NULL;
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
113 if (!item.findAndGetElement(tag, element).good())
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
114 {
3072
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
115 return isOptionalConstraint;
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
116 }
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
117
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
118 if (element == NULL)
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
119 {
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
120 return false;
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
121 }
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
122
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
123 std::set<DicomTag> ignoreTagLength;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3679
diff changeset
124 std::unique_ptr<DicomValue> value(FromDcmtkBridge::ConvertLeafElement
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3679
diff changeset
125 (*element, DicomToJsonFlags_None,
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3679
diff changeset
126 0, encoding, hasCodeExtensions, ignoreTagLength));
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
127
3072
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
128 // WARNING: Also modify "HierarchicalMatcher::Setup()" if modifying this code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
129 if (value.get() == NULL ||
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
130 value->IsNull())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
131 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
132 return isOptionalConstraint;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
133 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
134 else if (value->IsBinary() ||
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
135 !constraints_[i]->IsMatch(value->GetContent()))
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
136 {
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
137 return false;
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
138 }
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
139 }
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
140
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
141 return true;
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
142 }
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
143
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
144
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
145 void DatabaseLookup::AddDicomConstraintInternal(const DicomTag& tag,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
146 ValueRepresentation vr,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
147 const std::string& dicomQuery,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
148 bool caseSensitive,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
149 bool mandatoryTag)
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 if ((vr == ValueRepresentation_Date ||
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 vr == ValueRepresentation_DateTime ||
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 vr == ValueRepresentation_Time) &&
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 dicomQuery.find('-') != std::string::npos)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 /**
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 * Range matching is only defined for TM, DA and DT value
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 * representations. This code fixes issues 35 and 37.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 * Reference: "Range matching is not defined for types of
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 * Attributes other than dates and times", DICOM PS 3.4,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 * C.2.2.2.5 ("Range Matching").
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 **/
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 size_t separator = dicomQuery.find('-');
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 std::string lower = dicomQuery.substr(0, separator);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 std::string upper = dicomQuery.substr(separator + 1);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 if (!lower.empty())
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
170 AddConstraintInternal(new DicomTagConstraint
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
171 (tag, ConstraintType_GreaterOrEqual, lower, caseSensitive, mandatoryTag));
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 if (!upper.empty())
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
176 AddConstraintInternal(new DicomTagConstraint
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
177 (tag, ConstraintType_SmallerOrEqual, upper, caseSensitive, mandatoryTag));
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
180 else if (dicomQuery.find('\\') != std::string::npos)
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 DicomTag fixedTag(tag);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3679
diff changeset
184 std::unique_ptr<DicomTagConstraint> constraint
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2893
diff changeset
185 (new DicomTagConstraint(fixedTag, ConstraintType_List, caseSensitive, mandatoryTag));
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 std::vector<std::string> items;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 Toolbox::TokenizeString(items, dicomQuery, '\\');
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 for (size_t i = 0; i < items.size(); i++)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 constraint->AddValue(items[i]);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
195 AddConstraintInternal(constraint.release());
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
197 else if (
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
198 /**
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
199 * New test in Orthanc 1.6.0: Wild card matching is only allowed
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
200 * for a subset of value representations: AE, CS, LO, LT, PN,
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
201 * SH, ST, UC, UR, UT.
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
202 * http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.4.html
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
203 **/
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
204 (vr == ValueRepresentation_ApplicationEntity || // AE
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
205 vr == ValueRepresentation_CodeString || // CS
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
206 vr == ValueRepresentation_LongString || // LO
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
207 vr == ValueRepresentation_LongText || // LT
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
208 vr == ValueRepresentation_PersonName || // PN
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
209 vr == ValueRepresentation_ShortString || // SH
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
210 vr == ValueRepresentation_ShortText || // ST
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
211 vr == ValueRepresentation_UnlimitedCharacters || // UC
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
212 vr == ValueRepresentation_UniversalResource || // UR
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
213 vr == ValueRepresentation_UnlimitedText // UT
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
214 ) &&
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
215 (dicomQuery.find('*') != std::string::npos ||
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
216 dicomQuery.find('?') != std::string::npos))
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 {
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
218 AddConstraintInternal(new DicomTagConstraint
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
219 (tag, ConstraintType_Wildcard, dicomQuery, caseSensitive, mandatoryTag));
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 else
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
223 AddConstraintInternal(new DicomTagConstraint
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
224 (tag, ConstraintType_Equal, dicomQuery, caseSensitive, mandatoryTag));
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
227
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
228
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 void DatabaseLookup::AddDicomConstraint(const DicomTag& tag,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 const std::string& dicomQuery,
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
231 bool caseSensitivePN,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
232 bool mandatoryTag)
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(tag);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 if (vr == ValueRepresentation_Sequence)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 throw OrthancException(ErrorCode_ParameterOutOfRange);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 /**
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 * DICOM specifies that searches must always be case sensitive,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 * except for tags with a PN value representation. For PN, Orthanc
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 * uses the configuration option "CaseSensitivePN" to decide
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 * whether matching is case-sensitive or case-insensitive.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 * Reference: DICOM PS 3.4
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 * - C.2.2.2.1 ("Single Value Matching")
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 * - C.2.2.2.4 ("Wild Card Matching")
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 * http://medical.nema.org/Dicom/2011/11_04pu.pdf
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 * "Except for Attributes with a PN Value Representation, only
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 * entities with values which match exactly the value specified in the
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 * request shall match. This matching is case-sensitive, i.e.,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 * sensitive to the exact encoding of the key attribute value in
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 * character sets where a letter may have multiple encodings (e.g.,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 * based on its case, its position in a word, or whether it is
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 * accented)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 * For Attributes with a PN Value Representation (e.g., Patient Name
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 * (0010,0010)), an application may perform literal matching that is
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 * either case-sensitive, or that is insensitive to some or all
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 * aspects of case, position, accent, or other character encoding
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 * variants."
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 * (0008,0018) UI SOPInstanceUID => Case-sensitive
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 * (0008,0050) SH AccessionNumber => Case-sensitive
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 * (0010,0020) LO PatientID => Case-sensitive
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 * (0020,000D) UI StudyInstanceUID => Case-sensitive
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 * (0020,000E) UI SeriesInstanceUID => Case-sensitive
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 **/
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
272
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 if (vr == ValueRepresentation_PersonName)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 {
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
275 AddDicomConstraintInternal(tag, vr, dicomQuery, caseSensitivePN, mandatoryTag);
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 else
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 {
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
279 AddDicomConstraintInternal(tag, vr, dicomQuery, true /* case sensitive */, mandatoryTag);
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 }
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 }
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
282
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
283
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
284 void DatabaseLookup::AddRestConstraint(const DicomTag& tag,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
285 const std::string& dicomQuery,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
286 bool caseSensitive,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
287 bool mandatoryTag)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
288 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
289 AddDicomConstraintInternal(tag, FromDcmtkBridge::LookupValueRepresentation(tag),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
290 dicomQuery, caseSensitive, mandatoryTag);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
291 }
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
292
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
293
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
294 bool DatabaseLookup::HasOnlyMainDicomTags() const
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
295 {
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
296 std::set<DicomTag> mainTags;
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
297 DicomMap::GetMainDicomTags(mainTags);
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
298
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
299 for (size_t i = 0; i < constraints_.size(); i++)
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
300 {
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
301 assert(constraints_[i] != NULL);
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
302
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
303 if (mainTags.find(constraints_[i]->GetTag()) == mainTags.end())
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
304 {
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
305 // This is not a main DICOM tag
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
306 return false;
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
307 }
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
308 }
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
309
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
310 return true;
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
311 }
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
312
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
313
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
314 std::string DatabaseLookup::Format() const
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
315 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
316 std::string s;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
317
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
318 for (size_t i = 0; i < constraints_.size(); i++)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
319 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
320 assert(constraints_[i] != NULL);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
321 s += ("Contraint " + boost::lexical_cast<std::string>(i) + ": " +
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
322 constraints_[i]->Format() + "\n");
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
323 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
324
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
325 return s;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
326 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
327
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
328
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
329 bool DatabaseLookup::HasTag(const DicomTag& tag) const
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
330 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
331 for (size_t i = 0; i < constraints_.size(); i++)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
332 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
333 assert(constraints_[i] != NULL);
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
334 if (constraints_[i]->GetTag() == tag)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
335 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
336 return true;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
337 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
338 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
339
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
340 return false;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
341 }
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 }