Mercurial > hg > orthanc
changeset 5607:a3732285f8b6 find-refactoring
added main DICOM tags to ResourceFinder
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 May 2024 12:58:16 +0200 |
parents | 6e2dad336446 |
children | 3d0aa94b44b3 |
files | OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerContext.h |
diffstat | 3 files changed, 43 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Wed May 08 10:46:11 2024 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Wed May 08 12:58:16 2024 +0200 @@ -355,13 +355,15 @@ target["Status"] = EnumerationToString(status); + static const char* EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances"; + if (status == SeriesStatus_Unknown) { - target["ExpectedNumberOfInstances"] = Json::nullValue; + target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue; } else { - target["ExpectedNumberOfInstances"] = expectedNumberOfInstances; + target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances; } break; @@ -380,16 +382,18 @@ throw OrthancException(ErrorCode_InternalError); } + static const char* INDEX_IN_SERIES = "IndexInSeries"; + std::string s; uint32_t index; if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) && SerializationToolbox::ParseUnsignedInteger32(index, s)) { - target["IndexInSeries"] = index; + target[INDEX_IN_SERIES] = index; } else { - target["IndexInSeries"] = Json::nullValue; + target[INDEX_IN_SERIES] = Json::nullValue; } break; @@ -423,7 +427,42 @@ } { + static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; + static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags"; + // TODO-FIND : (expandFlags & ExpandResourceFlags_IncludeMainDicomTags) + DicomMap allMainDicomTags; + resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel()); + + DicomMap levelMainDicomTags; + allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel()); + + target[MAIN_DICOM_TAGS] = Json::objectValue; + FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format_); + + if (resource.GetLevel() == ResourceType_Study) + { + DicomMap patientMainDicomTags; + allMainDicomTags.ExtractPatientInformation(patientMainDicomTags); + + target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue; + FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format_); + } + + /* + TODO-FIND + + if (!requestedTags_.empty()) + { + static const char* const REQUESTED_TAGS = "RequestedTags"; + + DicomMap tags; + resource.GetMainDicomTags().ExtractTags(tags, requestedTags); + + target[REQUESTED_TAGS] = Json::objectValue; + FromDcmtkBridge::ToJson(target[REQUESTED_TAGS], tags, format); + } + */ } { @@ -524,15 +563,7 @@ { Json::Value item; Expand(item, response.GetResource(i), context.GetIndex()); - -#if 0 target.append(item); -#else - context.AppendFindResponse(target, request_, response.GetResource(i), format_, - requestedTags_, true /* allowStorageAccess */); - std::cout << "+++ Expected: " << target[target.size() - 1].toStyledString(); - std::cout << "--- Actual: " << item.toStyledString(); -#endif } } else
--- a/OrthancServer/Sources/ServerContext.cpp Wed May 08 10:46:11 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Wed May 08 12:58:16 2024 +0200 @@ -2716,43 +2716,4 @@ return elapsed.total_seconds(); } - - void ServerContext::AppendFindResponse(Json::Value& target, - const FindRequest& request, - const FindResponse::Resource& item, - DicomToJsonFormat format, - const std::set<DicomTag>& requestedTags, - bool allowStorageAccess) - { - // convert to ExpandedResource to re-use the serialization code TODO-FIND: check if this is the right way to do. shouldn't we copy the code and finally get rid of ExpandedResource ? - ExpandedResource resource(request, item); - - ExpandResourceFlags expandFlags = ExpandResourceFlags_None; - if (request.IsRetrieveChildrenIdentifiers()) - { - expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeChildren); - } - if (request.IsRetrieveMetadata(request.GetLevel())) - { - expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeAllMetadata | ExpandResourceFlags_IncludeMetadata ); - } - if (request.IsRetrieveMainDicomTags(request.GetLevel())) - { - expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeMainDicomTags); - } - if (true /* request.HasResponseContent(FindRequest::ResponseContent_IsStable) */) // TODO-FIND: Is this correct? - { - expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeIsStable); - } - if (request.IsRetrieveLabels()) - { - expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeLabels); - } - - Json::Value jsonItem; - SerializeExpandedResource(jsonItem, resource, format, requestedTags, expandFlags); - target.append(jsonItem); - } - - }
--- a/OrthancServer/Sources/ServerContext.h Wed May 08 10:46:11 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.h Wed May 08 12:58:16 2024 +0200 @@ -607,13 +607,6 @@ ExpandResourceFlags expandFlags, bool allowStorageAccess); - void AppendFindResponse(Json::Value& target, - const FindRequest& request, - const FindResponse::Resource& resource, - DicomToJsonFormat format, - const std::set<DicomTag>& requestedTags, - bool allowStorageAccess); - FindStorageAccessMode GetFindStorageAccessMode() const { return findStorageAccessMode_;