annotate OrthancServer/Sources/Search/DatabaseLookup.h @ 5663:3765085693e5 large-queries

merge default -> large-queries
author Alain Mazy <am@orthanc.team>
date Thu, 04 Jul 2024 07:40:58 +0200
parents f7adfb22e20e
children 0c218d90096e
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * 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
11 * published by the Free Software Foundation, either version 3 of the
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * 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
20 * 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
21 **/
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
26 #include "../Search/ISqlLookupFormatter.h"
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "DicomTagConstraint.h"
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
29 class DcmItem;
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
30
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace Orthanc
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 class DatabaseLookup : public boost::noncopyable
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 private:
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 std::vector<DicomTagConstraint*> constraints_;
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
37 std::set<std::string> labels_;
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
38 LabelsConstraint labelsConstraint_;
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
40 void AddDicomConstraintInternal(const DicomTag& tag,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
41 ValueRepresentation vr,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
42 const std::string& dicomQuery,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
43 bool caseSensitive,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
44 bool mandatoryTag);
3163
cf91b6f22278 Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
45
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
46 void AddConstraintInternal(DicomTagConstraint* constraint); // Takes ownership
3163
cf91b6f22278 Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3071
diff changeset
47
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 public:
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
49 DatabaseLookup() :
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
50 labelsConstraint_(LabelsConstraint_All)
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
51 {
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
52 }
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ~DatabaseLookup();
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
4977
dad71e6da406 pre-filtering studies without ModalitiesInStudies first
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
56 DatabaseLookup* Clone() const;
dad71e6da406 pre-filtering studies without ModalitiesInStudies first
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
57
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 void Reserve(size_t n)
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 constraints_.reserve(n);
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
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 size_t GetConstraintsCount() const
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 return constraints_.size();
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
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 const DicomTagConstraint& GetConstraint(size_t index) const;
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
4977
dad71e6da406 pre-filtering studies without ModalitiesInStudies first
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
70 bool GetConstraint(const DicomTagConstraint*& constraint, const DicomTag& tag) const;
dad71e6da406 pre-filtering studies without ModalitiesInStudies first
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
71
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
72 bool IsMatch(const DicomMap& value) const;
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
74 bool IsMatch(DcmItem& item,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3163
diff changeset
75 Encoding encoding,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3163
diff changeset
76 bool hasCodeExtensions) const;
3071
2df061cf2fec getting rid of IFindConstraint hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
77
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 void AddDicomConstraint(const DicomTag& tag,
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 const std::string& dicomQuery,
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
80 bool caseSensitivePN,
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
81 bool mandatoryTag);
3027
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
82
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
83 void AddRestConstraint(const DicomTag& tag,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
84 const std::string& dicomQuery,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
85 bool caseSensitive,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
86 bool mandatoryTag);
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
87
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
88 void AddConstraint(const DicomTagConstraint& constraint)
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
89 {
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
90 AddConstraintInternal(new DicomTagConstraint(constraint));
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
91 }
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
92
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3027
diff changeset
93 bool HasOnlyMainDicomTags() const;
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
94
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
95 std::string Format() const;
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
96
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
97 bool HasTag(const DicomTag& tag) const;
4977
dad71e6da406 pre-filtering studies without ModalitiesInStudies first
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
98
dad71e6da406 pre-filtering studies without ModalitiesInStudies first
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
99 void RemoveConstraint(const DicomTag& tag);
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
100
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
101 void AddLabel(const std::string& label);
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
102
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
103 void SetLabelsConstraint(LabelsConstraint constraint)
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
104 {
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
105 labelsConstraint_ = constraint;
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
106 }
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
107
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
108 const std::set<std::string>& GetLabels() const
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
109 {
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
110 return labels_;
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
111 }
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
112
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
113 LabelsConstraint GetLabelsConstraint() const
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
114 {
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
115 return labelsConstraint_;
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
116 }
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 };
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }