changeset 5752:717acb0ea546 find-refactoring

fix DICOMWeb integration tests
author Alain Mazy <am@orthanc.team>
date Tue, 03 Sep 2024 16:37:31 +0200
parents 5d78e5cafabc
children fc591f166d53
files NEWS OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Sources/ResourceFinder.cpp OrthancServer/Sources/Search/ISqlLookupFormatter.cpp
diffstat 4 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Sep 03 11:09:49 2024 +0200
+++ b/NEWS	Tue Sep 03 16:37:31 2024 +0200
@@ -2,7 +2,8 @@
 ===============================
 
 * TODO-FIND: complete the list of updated routes:
-  /studies?expand and sibbling routes now also return "Metadata" (if the DB implements 'extended-api-v1')
+  - /studies?expand and sibbling routes now also return "Metadata" (if the DB implements 'extended-api-v1')
+  - /studies?since=x&limit=0 and sibbling routes: limit=0 now means "no-limit" instead of "no-results"
 
 REST API
 --------
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Tue Sep 03 11:09:49 2024 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Tue Sep 03 16:37:31 2024 +0200
@@ -545,7 +545,7 @@
       // need resource labels ?
       if (request.IsRetrieveLabels())
       {
-        sql = "SELECT id, label "
+        sql = "SELECT Lookup.internalId, label "
               "FROM Labels "
               "INNER JOIN Lookup ON Labels.id = Lookup.internalId";
 
@@ -648,7 +648,7 @@
       // need children identifiers ?
       if (requestLevel <= ResourceType_Series && request.GetChildrenSpecification(static_cast<ResourceType>(requestLevel + 1)).IsRetrieveIdentifiers())
       {
-        sql = "SELECT currentLevel.internalId, childLevel.publicId "
+        sql = "SELECT Lookup.internalId, childLevel.publicId "
               "FROM Resources AS currentLevel "
               "INNER JOIN Lookup ON currentLevel.internalId = Lookup.internalId "
               "INNER JOIN Resources childLevel ON currentLevel.internalId = childLevel.parentId ";
@@ -664,7 +664,7 @@
       // need grandchildren identifiers ?
       if (requestLevel <= ResourceType_Study && request.GetChildrenSpecification(static_cast<ResourceType>(requestLevel + 2)).IsRetrieveIdentifiers())
       {
-        sql = "SELECT currentLevel.internalId, grandChildLevel.publicId "
+        sql = "SELECT Lookup.internalId, grandChildLevel.publicId "
               "FROM Resources AS currentLevel "
               "INNER JOIN Lookup ON currentLevel.internalId = Lookup.internalId "
               "INNER JOIN Resources childLevel ON currentLevel.internalId = childLevel.parentId "
@@ -681,7 +681,7 @@
       // need resource attachments ?
       if (request.IsRetrieveAttachments())
       {
-        sql = "SELECT id, fileType, uuid, uncompressedSize, compressedSize, compressionType, uncompressedMD5, compressedMD5 "
+        sql = "SELECT Lookup.internalId, fileType, uuid, uncompressedSize, compressedSize, compressionType, uncompressedMD5, compressedMD5 "
               "FROM AttachedFiles "
               "INNER JOIN Lookup ON AttachedFiles.id = Lookup.internalId";
 
--- a/OrthancServer/Sources/ResourceFinder.cpp	Tue Sep 03 11:09:49 2024 +0200
+++ b/OrthancServer/Sources/ResourceFinder.cpp	Tue Sep 03 16:37:31 2024 +0200
@@ -758,7 +758,14 @@
     {
       requestedComputedTags_.insert(tag);
       hasRequestedTags_ = true;
-      request_.GetChildrenSpecification(ResourceType_Series).AddMainDicomTag(DICOM_TAG_MODALITY);
+      if (request_.GetLevel() < ResourceType_Series)
+      {
+        request_.GetChildrenSpecification(ResourceType_Series).AddMainDicomTag(DICOM_TAG_MODALITY);
+      }
+      else if (request_.GetLevel() == ResourceType_Instance)  // this happens in QIDO-RS when searching for instances without specifying a StudyInstanceUID -> all Study level tags must be included in the response
+      {
+        request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true);
+      }
     }
     else if (tag == DICOM_TAG_INSTANCE_AVAILABILITY)
     {
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Tue Sep 03 11:09:49 2024 +0200
+++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Tue Sep 03 16:37:31 2024 +0200
@@ -752,8 +752,14 @@
 
     if (request.HasLimits())
     {
-      sql += " LIMIT " + boost::lexical_cast<std::string>(request.GetLimitsCount());
-      sql += " OFFSET " + boost::lexical_cast<std::string>(request.GetLimitsSince());
+      if (request.GetLimitsCount() > 0)
+      {
+        sql += " LIMIT " + boost::lexical_cast<std::string>(request.GetLimitsCount());
+      }
+      if (request.GetLimitsSince() > 0)
+      {
+        sql += " OFFSET " + boost::lexical_cast<std::string>(request.GetLimitsSince());
+      }
     }
 
   }