changeset 6150:73e9d9248cf3

IsProtected
author Alain Mazy <am@orthanc.team>
date Mon, 02 Jun 2025 12:28:45 +0200
parents 724eda38d990
children faa83997d9e7 255fcf2f8541
files NEWS OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp OrthancServer/Sources/ResourceFinder.cpp OrthancServer/Sources/ResourceFinder.h OrthancServer/Sources/ServerEnumerations.cpp OrthancServer/Sources/ServerEnumerations.h
diffstat 6 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Jun 02 11:33:54 2025 +0200
+++ b/NEWS	Mon Jun 02 12:28:45 2025 +0200
@@ -22,6 +22,15 @@
   "RejectedSopClasses" spelling.
 
 
+REST API
+--------
+
+* If the index database provides the "HasExtendedFind" primitive, the "ResponseContent" option in
+  "/tools/find" now allows to specify "IsProtected" to retrieve the "IsProtected" status of a
+  patient resource.
+
+
+
 Version 1.12.7 (2025-04-07)
 ===========================
 
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Mon Jun 02 11:33:54 2025 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Mon Jun 02 12:28:45 2025 +0200
@@ -705,8 +705,8 @@
     {
       call.GetDocumentation().SetHttpGetArgument(GET_RESPONSE_CONTENT, RestApiCallDocumentation::Type_String,
                             "Defines the content of response for each returned resource.  Allowed values are `MainDicomTags`, "
-                            "`Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`, `Attachments`.  If not specified, Orthanc "
-                            "will return `MainDicomTags`, `Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`."
+                            "`Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`, `IsProtected`, `Attachments`.  If not specified, Orthanc "
+                            "will return `MainDicomTags`, `Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`, `IsProtected`."
                             "e.g: '" + GET_RESPONSE_CONTENT + "=MainDicomTags;Children "
                             "(new in Orthanc 1.12.5 - overrides `expand`)", false);
 
@@ -719,8 +719,8 @@
       call.GetDocumentation().SetRequestField(POST_RESPONSE_CONTENT, RestApiCallDocumentation::Type_JsonListOfStrings,
                             "Defines the content of response for each returned resource. (this field, if present, overrides the \"Expand\" field).  "
                             "Allowed values are `MainDicomTags`, "
-                            "`Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`, `Attachments`.  If not specified, Orthanc "
-                            "will return `MainDicomTags`, `Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`."
+                            "`Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`, `IsProtected`, `Attachments`.  If not specified, Orthanc "
+                            "will return `MainDicomTags`, `Metadata`, `Children`, `Parent`, `Labels`, `Status`, `IsStable`, `IsProtected`."
                             "(new in Orthanc 1.12.5)", false);
 
       call.GetDocumentation().SetRequestField(POST_EXPAND, RestApiCallDocumentation::Type_Boolean,
--- a/OrthancServer/Sources/ResourceFinder.cpp	Mon Jun 02 11:33:54 2025 +0200
+++ b/OrthancServer/Sources/ResourceFinder.cpp	Mon Jun 02 12:28:45 2025 +0200
@@ -394,6 +394,14 @@
       }
     }
 
+    if (responseContent_ & ResponseContentFlags_IsProtected)
+    {
+      if (resource.GetLevel() == ResourceType_Patient )
+      {
+        target["IsProtected"] = index.IsProtectedPatient(resource.GetIdentifier());
+      }
+    }
+
     if (responseContent_ & ResponseContentFlags_MainDicomTags)
     {
       DicomMap allMainDicomTags;
--- a/OrthancServer/Sources/ResourceFinder.h	Mon Jun 02 11:33:54 2025 +0200
+++ b/OrthancServer/Sources/ResourceFinder.h	Mon Jun 02 12:28:45 2025 +0200
@@ -178,7 +178,7 @@
       request_.SetRetrieveAttachments(retrieve);
     }
 
-    // NB: "index" is only used in this method to fill the "IsStable" information
+    // NB: "index" is used in this method to fill the "IsStable" and "IsProtected" information
     void Expand(Json::Value& target,
                 const FindResponse::Resource& resource,
                 ServerIndex& index,
--- a/OrthancServer/Sources/ServerEnumerations.cpp	Mon Jun 02 11:33:54 2025 +0200
+++ b/OrthancServer/Sources/ServerEnumerations.cpp	Mon Jun 02 12:28:45 2025 +0200
@@ -655,6 +655,10 @@
     {
       return ResponseContentFlags_IsStable;
     }
+    else if (value == "IsProtected")
+    {
+      return ResponseContentFlags_IsProtected;
+    }
     else
     {
       throw OrthancException(ErrorCode_ParameterOutOfRange,
--- a/OrthancServer/Sources/ServerEnumerations.h	Mon Jun 02 11:33:54 2025 +0200
+++ b/OrthancServer/Sources/ServerEnumerations.h	Mon Jun 02 12:28:45 2025 +0200
@@ -136,6 +136,7 @@
     ResponseContentFlags_Children             = (1 << 10),
     ResponseContentFlags_Labels               = (1 << 11),
     ResponseContentFlags_IsStable             = (1 << 12),
+    ResponseContentFlags_IsProtected          = (1 << 13),
 
     ResponseContentFlags_INTERNAL_CountResources = (1 << 30),
     
@@ -150,7 +151,8 @@
                                         ResponseContentFlags_Parent | 
                                         ResponseContentFlags_Children | 
                                         ResponseContentFlags_Labels |
-                                        ResponseContentFlags_IsStable),  // equivalent to "Expand": true
+                                        ResponseContentFlags_IsStable |
+                                        ResponseContentFlags_IsProtected),  // equivalent to "Expand": true
     
     ResponseContentFlags_Default = (ResponseContentFlags_ID |
                                     ResponseContentFlags_Type |