comparison OrthancServer/Sources/Database/FindRequest.cpp @ 5614:4640b7ae9a11 find-refactoring

moving normalization of constraints into FindRequest
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 May 2024 11:59:56 +0200
parents d4b570834d3a
children 1864b16bc7b1
comparison
equal deleted inserted replaced
5613:f1ce8dd361b7 5614:4640b7ae9a11
22 22
23 #include "FindRequest.h" 23 #include "FindRequest.h"
24 24
25 #include "../../../OrthancFramework/Sources/OrthancException.h" 25 #include "../../../OrthancFramework/Sources/OrthancException.h"
26 26
27 #include "MainDicomTagsRegistry.h"
27 28
28 #include <cassert> 29 #include <cassert>
30
29 31
30 namespace Orthanc 32 namespace Orthanc
31 { 33 {
32 FindRequest::FindRequest(ResourceType level) : 34 FindRequest::FindRequest(ResourceType level) :
33 level_(level), 35 level_(level),
137 } 139 }
138 140
139 141
140 void FindRequest::AddDicomTagConstraint(const DicomTagConstraint& constraint) 142 void FindRequest::AddDicomTagConstraint(const DicomTagConstraint& constraint)
141 { 143 {
142 dicomTagConstraints_.push_back(constraint); 144 // This behaves like "StatelessDatabaseOperations::NormalizeLookup()" in Orthanc <= 1.12.3
143 } 145
144 146 if (mainDicomTagsRegistry_.get() == NULL)
145 const DicomTagConstraint& FindRequest::GetDicomTagConstraint(size_t index) const 147 {
148 // Lazy creation of the registry of main DICOM tags
149 mainDicomTagsRegistry_.reset(new MainDicomTagsRegistry());
150 }
151
152 ResourceType level;
153 DicomTagType type;
154
155 mainDicomTagsRegistry_->LookupTag(level, type, constraint.GetTag());
156
157 if (type == DicomTagType_Identifier ||
158 type == DicomTagType_Main)
159 {
160 // Use the fact that patient-level tags are copied at the study level
161 if (level == ResourceType_Patient &&
162 GetLevel() != ResourceType_Patient)
163 {
164 level = ResourceType_Study;
165 }
166
167 dicomTagConstraints_.push_back(constraint.ConvertToDatabaseConstraint(level, type));
168 }
169 }
170
171
172 const DatabaseConstraint& FindRequest::GetDicomTagConstraint(size_t index) const
146 { 173 {
147 if (index >= dicomTagConstraints_.size()) 174 if (index >= dicomTagConstraints_.size())
148 { 175 {
149 throw OrthancException(ErrorCode_ParameterOutOfRange); 176 throw OrthancException(ErrorCode_ParameterOutOfRange);
150 } 177 }