Mercurial > hg > orthanc
changeset 2986:b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 10 Dec 2018 10:03:41 +0100 |
parents | 32ec5078e32b |
children | 96089d1aba4d |
files | OrthancServer/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/QueryRetrieveHandler.cpp OrthancServer/QueryRetrieveHandler.h |
diffstat | 3 files changed, 54 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Mon Dec 10 09:20:57 2018 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Mon Dec 10 10:03:41 2018 +0100 @@ -708,7 +708,7 @@ template <ResourceType CHILDREN_LEVEL> - static void AnswerQueryChildren(RestApiPostCall& call) + static void QueryAnswerChildren(RestApiPostCall& call) { // New in Orthanc 1.4.3 assert(CHILDREN_LEVEL == ResourceType_Study || @@ -769,6 +769,35 @@ handler->SetQuery(it->first, it->second); } } + + DicomMap answer; + parent.GetHandler().GetAnswer(answer, index); + + // This switch-case mimics "DicomUserConnection::Move()" + switch (parent.GetHandler().GetLevel()) + { + case ResourceType_Patient: + handler->CopyStringTag(answer, DICOM_TAG_PATIENT_ID); + break; + + case ResourceType_Study: + handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID); + break; + + case ResourceType_Series: + handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID); + handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID); + break; + + case ResourceType_Instance: + handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID); + handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID); + handler->CopyStringTag(answer, DICOM_TAG_SOP_INSTANCE_UID); + break; + + default: + throw OrthancException(ErrorCode_InternalError); + } } } @@ -1234,11 +1263,11 @@ Register("/queries/{id}/answers/{index}/content", GetQueryOneAnswer); Register("/queries/{id}/answers/{index}/retrieve", RetrieveOneAnswer); Register("/queries/{id}/answers/{index}/query-instances", - AnswerQueryChildren<ResourceType_Instance>); + QueryAnswerChildren<ResourceType_Instance>); Register("/queries/{id}/answers/{index}/query-series", - AnswerQueryChildren<ResourceType_Series>); + QueryAnswerChildren<ResourceType_Series>); Register("/queries/{id}/answers/{index}/query-studies", - AnswerQueryChildren<ResourceType_Study>); + QueryAnswerChildren<ResourceType_Study>); Register("/queries/{id}/level", GetQueryLevel); Register("/queries/{id}/modality", GetQueryModality); Register("/queries/{id}/query", GetQueryArguments);
--- a/OrthancServer/QueryRetrieveHandler.cpp Mon Dec 10 09:20:57 2018 +0100 +++ b/OrthancServer/QueryRetrieveHandler.cpp Mon Dec 10 10:03:41 2018 +0100 @@ -142,6 +142,24 @@ } + void QueryRetrieveHandler::CopyStringTag(const DicomMap& from, + const DicomTag& tag) + { + const DicomValue* value = from.TestAndGetValue(tag); + + if (value == NULL || + value->IsNull() || + value->IsBinary()) + { + throw OrthancException(ErrorCode_InexistentTag); + } + else + { + SetQuery(tag, value->GetContent()); + } + } + + size_t QueryRetrieveHandler::GetAnswersCount() { Run();