# HG changeset patch # User Alain Mazy # Date 1735215492 -3600 # Node ID cc6027cbd8f14812be34e739ae5084b086657819 # Parent 3ef2ead6bb6c070e83244579ee38a795602d7478 prepared work for OE2 issue 73 diff -r 3ef2ead6bb6c -r cc6027cbd8f1 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Thu Dec 19 10:43:35 2024 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Thu Dec 26 13:18:12 2024 +0100 @@ -3072,6 +3072,26 @@ FindType_Count }; + static bool CanBePerformedInDb(const DatabaseLookup& lookup) + { + std::set nonMainDicomTags; + if (!lookup.HasOnlyMainDicomTags(nonMainDicomTags)) + { + // TODO: prepared work for https://github.com/orthanc-server/orthanc-explorer-2/issues/73 + + // // filtering on ModalitiesInStudy is actually performed in DB too although the tag is not stored in the MainDicomTags + // if (nonMainDicomTags.size() == 1 && nonMainDicomTags.find(DICOM_TAG_MODALITIES_IN_STUDY) != nonMainDicomTags.end()) + // { + // return true; + // } + + return false; + } + + return true; + } + + template static void Find(RestApiPostCall& call) { @@ -3319,7 +3339,7 @@ } } - if (requestType == FindType_Count && !dicomTagLookup.HasOnlyMainDicomTags()) + if (requestType == FindType_Count && !CanBePerformedInDb(dicomTagLookup)) { throw OrthancException(ErrorCode_BadRequest, "Unable to count resources when querying tags that are not stored as MainDicomTags in the Database"); @@ -3426,7 +3446,7 @@ if (((request.isMember(KEY_LIMIT) && request[KEY_LIMIT].asInt64() != 0) || (request.isMember(KEY_SINCE) && request[KEY_SINCE].asInt64() != 0)) && - !dicomTagLookup.HasOnlyMainDicomTags()) + !CanBePerformedInDb(dicomTagLookup)) { throw OrthancException(ErrorCode_BadRequest, "Unable to use " + std::string(KEY_LIMIT) + " or " + std::string(KEY_SINCE) + " in tools/find when querying tags that are not stored as MainDicomTags in the Database"); diff -r 3ef2ead6bb6c -r cc6027cbd8f1 OrthancServer/Sources/Search/DatabaseLookup.cpp --- a/OrthancServer/Sources/Search/DatabaseLookup.cpp Thu Dec 19 10:43:35 2024 +0100 +++ b/OrthancServer/Sources/Search/DatabaseLookup.cpp Thu Dec 26 13:18:12 2024 +0100 @@ -282,6 +282,14 @@ bool DatabaseLookup::HasOnlyMainDicomTags() const { + std::set notUsed; + + return HasOnlyMainDicomTags(notUsed); + } + + + bool DatabaseLookup::HasOnlyMainDicomTags(std::set& /* out*/ nonMainDicomTags) const + { std::set allMainTags; DicomMap::GetAllMainDicomTags(allMainTags); @@ -292,11 +300,11 @@ if (allMainTags.find(constraints_[i]->GetTag()) == allMainTags.end()) { // This is not a main DICOM tag - return false; + nonMainDicomTags.insert(constraints_[i]->GetTag()); } } - return true; + return nonMainDicomTags.size() == 0; } diff -r 3ef2ead6bb6c -r cc6027cbd8f1 OrthancServer/Sources/Search/DatabaseLookup.h --- a/OrthancServer/Sources/Search/DatabaseLookup.h Thu Dec 19 10:43:35 2024 +0100 +++ b/OrthancServer/Sources/Search/DatabaseLookup.h Thu Dec 26 13:18:12 2024 +0100 @@ -84,6 +84,8 @@ bool HasOnlyMainDicomTags() const; + bool HasOnlyMainDicomTags(std::set& /* out*/ nonMainDicomTags) const; + std::string Format() const; bool HasTag(const DicomTag& tag) const;