# HG changeset patch # User Sebastien Jodogne # Date 1445330361 -7200 # Node ID 3bcb010281075ccd140fa7b5a944f0e62f274d04 # Parent 88b74d8512bed703936449da3543b2a8893053c6 removed another flavor of ServerIndex::LookupIdentifier diff -r 88b74d8512be -r 3bcb01028107 OrthancServer/OrthancMoveRequestHandler.cpp --- a/OrthancServer/OrthancMoveRequestHandler.cpp Tue Oct 20 10:24:10 2015 +0200 +++ b/OrthancServer/OrthancMoveRequestHandler.cpp Tue Oct 20 10:39:21 2015 +0200 @@ -105,9 +105,11 @@ bool OrthancMoveRequestHandler::LookupIdentifier(std::string& publicId, - DicomTag tag, + ResourceType level, const DicomMap& input) { + DicomTag tag = GetIdentifierTag(level); + if (!input.HasTag(tag)) { return false; @@ -116,7 +118,7 @@ std::string value = input.GetValue(tag).AsString(); std::list ids; - context_.GetIndex().LookupIdentifier(ids, tag, value); + context_.GetIndex().LookupIdentifier(ids, tag, value, level); if (ids.size() != 1) { @@ -156,14 +158,9 @@ * Retrieve the query level. **/ - ResourceType level; const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); - if (levelTmp != NULL) - { - level = StringToResourceType(levelTmp->AsString().c_str()); - } - else + if (levelTmp == NULL) { // The query level is not present in the C-Move request, which // does not follow the DICOM standard. This is for instance the @@ -173,10 +170,10 @@ std::string publicId; - if (LookupIdentifier(publicId, DICOM_TAG_SOP_INSTANCE_UID, input) || - LookupIdentifier(publicId, DICOM_TAG_SERIES_INSTANCE_UID, input) || - LookupIdentifier(publicId, DICOM_TAG_STUDY_INSTANCE_UID, input) || - LookupIdentifier(publicId, DICOM_TAG_PATIENT_ID, input)) + if (LookupIdentifier(publicId, ResourceType_Instance, input) || + LookupIdentifier(publicId, ResourceType_Series, input) || + LookupIdentifier(publicId, ResourceType_Study, input) || + LookupIdentifier(publicId, ResourceType_Patient, input)) { return new OrthancMoveRequestIterator(context_, targetAet, publicId); } @@ -187,42 +184,23 @@ } } + assert(levelTmp != NULL); + ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); /** * Lookup for the resource to be sent. **/ - bool ok; std::string publicId; - switch (level) + if (LookupIdentifier(publicId, level, input)) { - case ResourceType_Patient: - ok = LookupIdentifier(publicId, DICOM_TAG_PATIENT_ID, input); - break; - - case ResourceType_Study: - ok = LookupIdentifier(publicId, DICOM_TAG_STUDY_INSTANCE_UID, input); - break; - - case ResourceType_Series: - ok = LookupIdentifier(publicId, DICOM_TAG_SERIES_INSTANCE_UID, input); - break; - - case ResourceType_Instance: - ok = LookupIdentifier(publicId, DICOM_TAG_SOP_INSTANCE_UID, input); - break; - - default: - ok = false; + return new OrthancMoveRequestIterator(context_, targetAet, publicId); } - - if (!ok) + else { throw OrthancException(ErrorCode_BadRequest); } - - return new OrthancMoveRequestIterator(context_, targetAet, publicId); } } diff -r 88b74d8512be -r 3bcb01028107 OrthancServer/OrthancMoveRequestHandler.h --- a/OrthancServer/OrthancMoveRequestHandler.h Tue Oct 20 10:24:10 2015 +0200 +++ b/OrthancServer/OrthancMoveRequestHandler.h Tue Oct 20 10:39:21 2015 +0200 @@ -42,7 +42,7 @@ ServerContext& context_; bool LookupIdentifier(std::string& publicId, - DicomTag tag, + ResourceType level, const DicomMap& input); public: diff -r 88b74d8512be -r 3bcb01028107 OrthancServer/ServerEnumerations.cpp --- a/OrthancServer/ServerEnumerations.cpp Tue Oct 20 10:24:10 2015 +0200 +++ b/OrthancServer/ServerEnumerations.cpp Tue Oct 20 10:39:21 2015 +0200 @@ -365,4 +365,25 @@ } } + + DicomTag GetIdentifierTag(ResourceType level) + { + switch (level) + { + case ResourceType_Patient: + return DICOM_TAG_PATIENT_ID; + + case ResourceType_Study: + return DICOM_TAG_STUDY_INSTANCE_UID; + + case ResourceType_Series: + return DICOM_TAG_SERIES_INSTANCE_UID; + + case ResourceType_Instance: + return DICOM_TAG_SOP_INSTANCE_UID; + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + } } diff -r 88b74d8512be -r 3bcb01028107 OrthancServer/ServerEnumerations.h --- a/OrthancServer/ServerEnumerations.h Tue Oct 20 10:24:10 2015 +0200 +++ b/OrthancServer/ServerEnumerations.h Tue Oct 20 10:39:21 2015 +0200 @@ -35,6 +35,7 @@ #include #include "../Core/Enumerations.h" +#include "../Core/DicomFormat/DicomTag.h" namespace Orthanc { @@ -194,4 +195,6 @@ const char* EnumerationToString(TransferSyntax syntax); ModalityManufacturer StringToModalityManufacturer(const std::string& manufacturer); + + DicomTag GetIdentifierTag(ResourceType level); } diff -r 88b74d8512be -r 3bcb01028107 OrthancServer/ServerIndex.cpp --- a/OrthancServer/ServerIndex.cpp Tue Oct 20 10:24:10 2015 +0200 +++ b/OrthancServer/ServerIndex.cpp Tue Oct 20 10:39:21 2015 +0200 @@ -1911,25 +1911,6 @@ } - void ServerIndex::LookupIdentifier(std::list& result, - const DicomTag& tag, - const std::string& value) - { - result.clear(); - - boost::mutex::scoped_lock lock(mutex_); - - std::list id; - db_.LookupIdentifier(id, tag, value); - - for (std::list::const_iterator - it = id.begin(); it != id.end(); ++it) - { - result.push_back(db_.GetPublicId(*it)); - } - } - - StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment, const std::string& publicId) { diff -r 88b74d8512be -r 3bcb01028107 OrthancServer/ServerIndex.h --- a/OrthancServer/ServerIndex.h Tue Oct 20 10:24:10 2015 +0200 +++ b/OrthancServer/ServerIndex.h Tue Oct 20 10:39:21 2015 +0200 @@ -241,10 +241,6 @@ const std::string& value, ResourceType type); - void LookupIdentifier(std::list& result, - const DicomTag& tag, - const std::string& value); - StoreStatus AddAttachment(const FileInfo& attachment, const std::string& publicId);