Mercurial > hg > orthanc
annotate OrthancServer/Search/IFindConstraint.cpp @ 3059:caa03eaeb097 db-changes
fix to use from orthanc-databases
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 21 Dec 2018 17:25:12 +0100 |
parents | 8fd203510d8b |
children | ce272138f15e |
rev | line source |
---|---|
1791 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1791 | 4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
1791 | 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 #include "../PrecompiledHeadersServer.h" | |
35 #include "IFindConstraint.h" | |
36 | |
37 #include "ListConstraint.h" | |
38 #include "RangeConstraint.h" | |
39 #include "ValueConstraint.h" | |
40 #include "WildcardConstraint.h" | |
41 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
42 #include "../../Core/DicomParsing/FromDcmtkBridge.h" |
1792 | 43 #include "../../Core/OrthancException.h" |
3036
8fd203510d8b
moving LookupIdentifierQuery to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
44 #include "../../Core/Toolbox.h" |
1792 | 45 |
1791 | 46 namespace Orthanc |
47 { | |
48 IFindConstraint* IFindConstraint::ParseDicomConstraint(const DicomTag& tag, | |
49 const std::string& dicomQuery, | |
50 bool caseSensitive) | |
51 { | |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
52 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(tag); |
1791 | 53 |
1792 | 54 if (vr == ValueRepresentation_Sequence) |
55 { | |
56 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
57 } | |
58 | |
1791 | 59 if ((vr == ValueRepresentation_Date || |
60 vr == ValueRepresentation_DateTime || | |
61 vr == ValueRepresentation_Time) && | |
62 dicomQuery.find('-') != std::string::npos) | |
63 { | |
64 /** | |
65 * Range matching is only defined for TM, DA and DT value | |
66 * representations. This code fixes issues 35 and 37. | |
67 * | |
68 * Reference: "Range matching is not defined for types of | |
69 * Attributes other than dates and times", DICOM PS 3.4, | |
70 * C.2.2.2.5 ("Range Matching"). | |
71 **/ | |
72 size_t separator = dicomQuery.find('-'); | |
73 std::string lower = dicomQuery.substr(0, separator); | |
74 std::string upper = dicomQuery.substr(separator + 1); | |
75 return new RangeConstraint(lower, upper, caseSensitive); | |
76 } | |
77 else if (dicomQuery.find('\\') != std::string::npos) | |
78 { | |
79 std::auto_ptr<ListConstraint> constraint(new ListConstraint(caseSensitive)); | |
80 | |
81 std::vector<std::string> items; | |
82 Toolbox::TokenizeString(items, dicomQuery, '\\'); | |
83 | |
84 for (size_t i = 0; i < items.size(); i++) | |
85 { | |
86 constraint->AddAllowedValue(items[i]); | |
87 } | |
88 | |
89 return constraint.release(); | |
90 } | |
91 else if (dicomQuery.find('*') != std::string::npos || | |
92 dicomQuery.find('?') != std::string::npos) | |
93 { | |
94 return new WildcardConstraint(dicomQuery, caseSensitive); | |
95 } | |
96 else | |
97 { | |
98 /** | |
99 * Case-insensitive match for PN value representation (Patient | |
100 * Name). Case-senstive match for all the other value | |
101 * representations. | |
102 * | |
103 * Reference: DICOM PS 3.4 | |
104 * - C.2.2.2.1 ("Single Value Matching") | |
105 * - C.2.2.2.4 ("Wild Card Matching") | |
106 * http://medical.nema.org/Dicom/2011/11_04pu.pdf | |
107 * | |
108 * "Except for Attributes with a PN Value Representation, only | |
109 * entities with values which match exactly the value specified in the | |
110 * request shall match. This matching is case-sensitive, i.e., | |
111 * sensitive to the exact encoding of the key attribute value in | |
112 * character sets where a letter may have multiple encodings (e.g., | |
113 * based on its case, its position in a word, or whether it is | |
114 * accented) | |
115 * | |
116 * For Attributes with a PN Value Representation (e.g., Patient Name | |
117 * (0010,0010)), an application may perform literal matching that is | |
118 * either case-sensitive, or that is insensitive to some or all | |
119 * aspects of case, position, accent, or other character encoding | |
120 * variants." | |
121 * | |
122 * (0008,0018) UI SOPInstanceUID => Case-sensitive | |
123 * (0008,0050) SH AccessionNumber => Case-sensitive | |
124 * (0010,0020) LO PatientID => Case-sensitive | |
125 * (0020,000D) UI StudyInstanceUID => Case-sensitive | |
126 * (0020,000E) UI SeriesInstanceUID => Case-sensitive | |
127 **/ | |
128 | |
129 return new ValueConstraint(dicomQuery, caseSensitive); | |
130 } | |
131 } | |
132 } |