diff OrthancServer/Sources/ResourceFinder.cpp @ 5620:4bfd885fb45f find-refactoring

optimization as patient-level tags are copied at study level
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 11 May 2024 15:11:22 +0200
parents 1864b16bc7b1
children 732ec9feeea8
line wrap: on
line diff
--- a/OrthancServer/Sources/ResourceFinder.cpp	Sat May 11 12:13:31 2024 +0200
+++ b/OrthancServer/Sources/ResourceFinder.cpp	Sat May 11 15:11:22 2024 +0200
@@ -397,9 +397,22 @@
   {
     if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient))
     {
-      request_.GetParentRetrieveSpecification(ResourceType_Patient).SetRetrieveMainDicomTags(true);
-      request_.GetParentRetrieveSpecification(ResourceType_Patient).SetRetrieveMetadata(true);
-      requestedPatientTags_.insert(tag);
+      if (request_.GetLevel() == ResourceType_Patient)
+      {
+        request_.GetParentRetrieveSpecification(ResourceType_Patient).SetRetrieveMainDicomTags(true);
+        request_.GetParentRetrieveSpecification(ResourceType_Patient).SetRetrieveMetadata(true);
+        requestedPatientTags_.insert(tag);
+      }
+      else
+      {
+        /**
+         * This comes from the fact that patient-level tags are copied
+         * at the study level, as implemented by "ResourcesContent::AddResource()".
+         **/
+        request_.GetParentRetrieveSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
+        request_.GetParentRetrieveSpecification(ResourceType_Study).SetRetrieveMetadata(true);
+        requestedStudyTags_.insert(tag);
+      }
     }
     else if (DicomMap::IsMainDicomTag(tag, ResourceType_Study))
     {