Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindRequest.cpp Thu May 09 11:32:06 2024 +0200 +++ b/OrthancServer/Sources/Database/FindRequest.cpp Thu May 09 11:59:56 2024 +0200 @@ -24,9 +24,11 @@ #include "../../../OrthancFramework/Sources/OrthancException.h" +#include "MainDicomTagsRegistry.h" #include <cassert> + namespace Orthanc { FindRequest::FindRequest(ResourceType level) : @@ -139,10 +141,35 @@ void FindRequest::AddDicomTagConstraint(const DicomTagConstraint& constraint) { - dicomTagConstraints_.push_back(constraint); + // This behaves like "StatelessDatabaseOperations::NormalizeLookup()" in Orthanc <= 1.12.3 + + if (mainDicomTagsRegistry_.get() == NULL) + { + // Lazy creation of the registry of main DICOM tags + mainDicomTagsRegistry_.reset(new MainDicomTagsRegistry()); + } + + ResourceType level; + DicomTagType type; + + mainDicomTagsRegistry_->LookupTag(level, type, constraint.GetTag()); + + if (type == DicomTagType_Identifier || + type == DicomTagType_Main) + { + // Use the fact that patient-level tags are copied at the study level + if (level == ResourceType_Patient && + GetLevel() != ResourceType_Patient) + { + level = ResourceType_Study; + } + + dicomTagConstraints_.push_back(constraint.ConvertToDatabaseConstraint(level, type)); + } } - const DicomTagConstraint& FindRequest::GetDicomTagConstraint(size_t index) const + + const DatabaseConstraint& FindRequest::GetDicomTagConstraint(size_t index) const { if (index >= dicomTagConstraints_.size()) {