diff OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5606:6e2dad336446 find-refactoring

added "IsStable" field in expanded resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 May 2024 10:46:11 +0200
parents e4e7ca3d206e
children a3732285f8b6
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Wed May 08 10:30:57 2024 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Wed May 08 10:46:11 2024 +0200
@@ -268,29 +268,10 @@
 
 
     void Expand(Json::Value& target,
-                const FindResponse::Resource& resource) const
+                const FindResponse::Resource& resource,
+                ServerIndex& index) const
     {
       /**
-
-         TODO-FIND:
-
-         - Metadata / Series / ExpectedNumberOfInstances
-
-         - Metadata / Series / Status
-
-         - Metadata / Instance / FileSize
-
-         - Metadata / Instance / FileUuid
-
-         - Metadata / Instance / IndexInSeries
-
-         - Metadata / AnonymizedFrom
-
-         - Metadata / ModifiedFrom
-
-      **/
-
-      /**
        * This method closely follows "SerializeExpandedResource()" in
        * "ServerContext.cpp" from Orthanc 1.12.3.
        **/
@@ -300,6 +281,11 @@
         throw OrthancException(ErrorCode_InternalError);
       }
 
+      if (!requestedTags_.empty())
+      {
+        throw OrthancException(ErrorCode_NotImplemented);
+      }
+
       target = Json::objectValue;
 
       target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true);
@@ -428,14 +414,7 @@
           resource.GetLevel() == ResourceType_Study ||
           resource.GetLevel() == ResourceType_Series)
       {
-        // TODO-FIND: Stable
-
-        /*
-          if (resource.IsStable())
-        {
-          target["IsStable"] = true;
-        }
-        */
+        target["IsStable"] = !index.IsUnstableResource(resource.GetLevel(), resource.GetInternalId());
 
         if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_LastUpdate))
         {
@@ -444,6 +423,10 @@
       }
 
       {
+        // TODO-FIND : (expandFlags & ExpandResourceFlags_IncludeMainDicomTags)
+      }
+
+      {
         Json::Value labels = Json::arrayValue;
 
         for (std::set<std::string>::const_iterator
@@ -455,7 +438,7 @@
         target["Labels"] = labels;
       }
 
-      if (includeAllMetadata_)
+      if (includeAllMetadata_)  // new in Orthanc 1.12.4
       {
         const std::map<MetadataType, std::string>& m = resource.GetMetadata(resource.GetLevel());
 
@@ -540,7 +523,7 @@
         for (size_t i = 0; i < response.GetSize(); i++)
         {
           Json::Value item;
-          Expand(item, response.GetResource(i));
+          Expand(item, response.GetResource(i), context.GetIndex());
 
 #if 0
           target.append(item);