changeset 5668:bd1352bd9d82 find-refactoring

configuring requests for ModalitiesInStudy and SOPClassesInStudy
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Jul 2024 21:57:39 +0200
parents 93dff1fccf36
children 56859a7ffa99
files OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/Database/FindRequest.h OrthancServer/Sources/ResourceFinder.cpp
diffstat 3 files changed, 77 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Thu Jul 04 21:31:48 2024 +0200
+++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Thu Jul 04 21:57:39 2024 +0200
@@ -474,8 +474,7 @@
 
           if (request.GetChildrenRetrieveSpecification(childrenLevel).IsRetrieveIdentifiers())
           {
-            for (std::list<int64_t>::const_iterator it = currentIds.begin();
-                 it != currentIds.end(); ++it)
+            for (std::list<int64_t>::const_iterator it = currentIds.begin(); it != currentIds.end(); ++it)
             {
               std::list<std::string> ids;
               transaction_.GetChildrenPublicId(ids, *it);
@@ -487,7 +486,27 @@
             }
           }
 
-          if (childrenLevel != bottomLevel)
+          const std::set<MetadataType>& metadata = request.GetChildrenRetrieveSpecification(childrenLevel).GetMetadata();
+
+          for (std::set<MetadataType>::const_iterator it = metadata.begin(); it != metadata.end(); ++it)
+          {
+            for (std::list<int64_t>::const_iterator it2 = currentIds.begin(); it2 != currentIds.end(); ++it2)
+            {
+              std::list<std::string> values;
+              transaction_.GetChildrenMetadata(values, *it2, *it);
+
+              for (std::list<std::string>::const_iterator it3 = values.begin(); it3 != values.end(); ++it3)
+              {
+                // TODO-FIND - Inject this value in the response
+                printf("[%s]\n", it3->c_str());
+              }
+            }
+          }
+
+          const std::set<DicomTag>& mainDicomTags = request.GetChildrenRetrieveSpecification(childrenLevel).GetMainDicomTags();
+
+          if (childrenLevel != bottomLevel ||
+              !mainDicomTags.empty())
           {
             std::list<int64_t> childrenIds;
 
@@ -499,6 +518,25 @@
               childrenIds.splice(childrenIds.end(), tmp);
             }
 
+            if (!mainDicomTags.empty())
+            {
+              for (std::list<int64_t>::const_iterator it = childrenIds.begin(); it != childrenIds.end(); ++it)
+              {
+                DicomMap m;
+                transaction_.GetMainDicomTags(m, *it);
+
+                for (std::set<DicomTag>::const_iterator it2 = mainDicomTags.begin(); it2 != mainDicomTags.end(); ++it2)
+                {
+                  std::string value;
+                  if (m.LookupStringValue(value, *it2, false /* no binary allowed */))
+                  {
+                    // TODO-FIND - Inject this value in the response
+                    printf("<%s>\n", value.c_str());
+                  }
+                }
+              }
+            }
+
             currentIds = childrenIds;
           }
           else
--- a/OrthancServer/Sources/Database/FindRequest.h	Thu Jul 04 21:31:48 2024 +0200
+++ b/OrthancServer/Sources/Database/FindRequest.h	Thu Jul 04 21:57:39 2024 +0200
@@ -198,7 +198,9 @@
     class ChildrenRetrieveSpecification : public boost::noncopyable
     {
     private:
-      bool  identifiers_;
+      bool                    identifiers_;
+      std::set<MetadataType>  metadata_;
+      std::set<DicomTag>      mainDicomTags_;
 
     public:
       ChildrenRetrieveSpecification() :
@@ -216,9 +218,29 @@
         return identifiers_;
       }
 
+      void AddMetadata(MetadataType metadata)
+      {
+        metadata_.insert(metadata);
+      }
+
+      const std::set<MetadataType>& GetMetadata() const
+      {
+        return metadata_;
+      }
+
+      void AddMainDicomTag(const DicomTag& tag)
+      {
+        mainDicomTags_.insert(tag);
+      }
+
+      const std::set<DicomTag>& GetMainDicomTags() const
+      {
+        return mainDicomTags_;
+      }
+
       bool IsOfInterest() const
       {
-        return identifiers_;
+        return (identifiers_ || !metadata_.empty() || !mainDicomTags_.empty());
       }
     };
 
--- a/OrthancServer/Sources/ResourceFinder.cpp	Thu Jul 04 21:31:48 2024 +0200
+++ b/OrthancServer/Sources/ResourceFinder.cpp	Thu Jul 04 21:57:39 2024 +0200
@@ -537,6 +537,18 @@
     {
       ConfigureChildrenCountComputedTag(tag, ResourceType_Series, ResourceType_Instance);
     }
+    else if (tag == DICOM_TAG_SOP_CLASSES_IN_STUDY)
+    {
+      requestedComputedTags_.insert(tag);
+      hasRequestedTags_ = true;
+      request_.GetChildrenRetrieveSpecification(ResourceType_Instance).AddMetadata(MetadataType_Instance_SopClassUid);
+    }
+    else if (tag == DICOM_TAG_MODALITIES_IN_STUDY)
+    {
+      requestedComputedTags_.insert(tag);
+      hasRequestedTags_ = true;
+      request_.GetChildrenRetrieveSpecification(ResourceType_Series).AddMainDicomTag(DICOM_TAG_MODALITY);
+    }
     else if (tag == DICOM_TAG_INSTANCE_AVAILABILITY)
     {
       requestedComputedTags_.insert(tag);