Mercurial > hg > orthanc
view OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5554:12d8a1a266e9 find-refactoring
introduction of FindRequest and FindResponse
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Apr 2024 16:13:24 +0200 |
parents | |
children | def06a42e5ef |
line wrap: on
line source
/** * Orthanc - A Lightweight, RESTful DICOM Store * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics * Department, University Hospital of Liege, Belgium * Copyright (C) 2017-2024 Osimis S.A., Belgium * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ #include "GenericFind.h" #include "../../../../OrthancFramework/Sources/OrthancException.h" namespace Orthanc { namespace Compatibility { void GenericFind::Execute(FindResponse& response, const FindRequest& request) { if (request.GetResponseType() == FindRequest::ResponseType_OrthancIdentifiers && !request.GetOrthancIdentifiers().HasPatientId() && !request.GetOrthancIdentifiers().HasStudyId() && !request.GetOrthancIdentifiers().HasSeriesId() && !request.GetOrthancIdentifiers().HasInstanceId() && request.GetTagConstraintsCount() == 0 && request.GetMetadataMode() == FindRequest::MetadataMode_None && !request.IsRetrieveTagsAtLevel(ResourceType_Patient) && !request.IsRetrieveTagsAtLevel(ResourceType_Study) && !request.IsRetrieveTagsAtLevel(ResourceType_Series) && !request.IsRetrieveTagsAtLevel(ResourceType_Instance) && request.GetTagOrdering().empty() && request.GetLabels().empty() && request.GetMetadataConstraints().empty()) { std::list<std::string> ids; if (request.HasLimits()) { transaction_.GetAllPublicIds(ids, request.GetLevel(), request.GetLimitsSince(), request.GetLimitsCount()); } else { transaction_.GetAllPublicIds(ids, request.GetLevel()); } for (std::list<std::string>::const_iterator it = ids.begin(); it != ids.end(); ++it) { OrthancIdentifiers identifiers; identifiers.SetLevel(request.GetLevel(), *it); response.Add(new FindResponse::Item(request.GetLevel(), identifiers)); } } else { throw OrthancException(ErrorCode_NotImplemented); } /** * Sanity checks **/ for (size_t i = 0; i < response.GetSize(); i++) { const FindResponse::Item& item = response.GetItem(i); if (item.GetLevel() != request.GetLevel()) { throw OrthancException(ErrorCode_InternalError); } switch (request.GetResponseType()) { case FindRequest::ResponseType_OrthancIdentifiers: break; case FindRequest::ResponseType_DicomMap: if (!item.HasDicomMap()) { throw OrthancException(ErrorCode_InternalError); } break; default: throw OrthancException(ErrorCode_NotImplemented); } } } } }