annotate OrthancServer/Sources/Database/FindRequest.cpp @ 5568:b0b5546f1b9f find-refactoring

find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
author Alain Mazy <am@orthanc.team>
date Thu, 25 Apr 2024 09:22:07 +0200
parents f3562c1a150d
children 8b32213af23e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "FindRequest.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../../../OrthancFramework/Sources/OrthancException.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <cassert>
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace Orthanc
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 bool FindRequest::IsCompatibleLevel(ResourceType levelOfInterest) const
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 switch (level_)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 case ResourceType_Patient:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 return (levelOfInterest == ResourceType_Patient);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 case ResourceType_Study:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 return (levelOfInterest == ResourceType_Patient ||
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 levelOfInterest == ResourceType_Study);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 case ResourceType_Series:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 return (levelOfInterest == ResourceType_Patient ||
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 levelOfInterest == ResourceType_Study ||
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 levelOfInterest == ResourceType_Series);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 case ResourceType_Instance:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 return (levelOfInterest == ResourceType_Patient ||
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 levelOfInterest == ResourceType_Study ||
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 levelOfInterest == ResourceType_Series ||
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 levelOfInterest == ResourceType_Instance);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 default:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 throw OrthancException(ErrorCode_ParameterOutOfRange);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 FindRequest::FindRequest(ResourceType level) :
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 level_(level),
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 hasLimits_(false),
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 limitsSince_(0),
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 limitsCount_(0),
5567
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
65 responseContent_(ResponseContent_IdentifiersOnly),
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 retrievePatientTags_(false),
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 retrieveStudyTags_(false),
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 retrieveSeriesTags_(false),
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 retrieveInstanceTags_(false)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 FindRequest::~FindRequest()
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
5567
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
76
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
77 for (std::deque<Ordering*>::iterator it = ordering_.begin(); it != ordering_.end(); ++it)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 assert(*it != NULL);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 delete *it;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
5568
b0b5546f1b9f find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents: 5567
diff changeset
84 void FindRequest::AddDicomTagConstraint(const DicomTagConstraint& constraint)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
5568
b0b5546f1b9f find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents: 5567
diff changeset
86 dicomTagConstraints_.push_back(constraint);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
5568
b0b5546f1b9f find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents: 5567
diff changeset
89 const DicomTagConstraint& FindRequest::GetDicomTagConstraint(size_t index) const
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 {
5568
b0b5546f1b9f find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents: 5567
diff changeset
91 if (index >= dicomTagConstraints_.size())
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 throw OrthancException(ErrorCode_ParameterOutOfRange);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
5568
b0b5546f1b9f find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents: 5567
diff changeset
97 return dicomTagConstraints_[index];
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 void FindRequest::SetLimits(uint64_t since,
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 uint64_t count)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 if (hasLimits_)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 throw OrthancException(ErrorCode_BadSequenceOfCalls);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 hasLimits_ = true;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 limitsSince_ = since;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 limitsCount_ = count;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 uint64_t FindRequest::GetLimitsSince() const
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 if (hasLimits_)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 return limitsSince_;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 throw OrthancException(ErrorCode_BadSequenceOfCalls);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 uint64_t FindRequest::GetLimitsCount() const
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 if (hasLimits_)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 return limitsCount_;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 throw OrthancException(ErrorCode_BadSequenceOfCalls);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 void FindRequest::SetRetrieveTagsAtLevel(ResourceType levelOfInterest,
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 bool retrieve)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 if (!IsCompatibleLevel(levelOfInterest))
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 throw OrthancException(ErrorCode_ParameterOutOfRange);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 switch (levelOfInterest)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 case ResourceType_Patient:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 retrievePatientTags_ = true;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 break;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 case ResourceType_Study:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 retrieveStudyTags_ = true;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 break;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 case ResourceType_Series:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 retrieveSeriesTags_ = true;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 break;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 case ResourceType_Instance:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 retrieveInstanceTags_ = true;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 break;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 default:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 throw OrthancException(ErrorCode_ParameterOutOfRange);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 bool FindRequest::IsRetrieveTagsAtLevel(ResourceType levelOfInterest) const
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 switch (levelOfInterest)
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 case ResourceType_Patient:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 return retrievePatientTags_;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 case ResourceType_Study:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 return retrieveStudyTags_;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 case ResourceType_Series:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 return retrieveSeriesTags_;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 case ResourceType_Instance:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 return retrieveInstanceTags_;
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 default:
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 throw OrthancException(ErrorCode_ParameterOutOfRange);
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
5567
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
198 void FindRequest::AddOrdering(const DicomTag& tag,
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
199 OrderingDirection direction)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 {
5567
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
201 ordering_.push_back(new Ordering(Key(tag), direction));
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
5567
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
204 void FindRequest::AddOrdering(MetadataType metadataType,
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
205 OrderingDirection direction)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
5567
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
207 ordering_.push_back(new Ordering(Key(metadataType), direction));
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 }
5567
f3562c1a150d FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents: 5565
diff changeset
209
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }