diff Samples/FHIR/src/main/java/OrthancResource.java @ 14:0dc05fe76bd5

implemented paging in Patient and ImagingStudy resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 21 Oct 2023 16:41:59 +0200
parents 8d876a4f541b
children b69bc09e2969
line wrap: on
line diff
--- a/Samples/FHIR/src/main/java/OrthancResource.java	Sat Oct 21 10:41:01 2023 +0200
+++ b/Samples/FHIR/src/main/java/OrthancResource.java	Sat Oct 21 16:41:59 2023 +0200
@@ -1,7 +1,7 @@
 /**
  * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
  * SPDX-License-Identifier: GPL-3.0-or-later
- */
+ **/
 
 /**
  * Java plugin for Orthanc
@@ -119,10 +119,13 @@
         }
     }
 
-    public static List<OrthancResource> find(IOrthancConnection connection,
-                                             ResourceType type,
-                                             Map<String, String> tags,
-                                             boolean caseSensitive) {
+    private static List<OrthancResource> find(IOrthancConnection connection,
+                                              ResourceType type,
+                                              Map<String, String> tags,
+                                              boolean caseSensitive,
+                                              boolean hasPaging,
+                                              int since,
+                                              int limit) {
         JSONObject query = new JSONObject();
         for (Map.Entry<String, String> entry : tags.entrySet()) {
             query.put(entry.getKey(), entry.getValue());
@@ -134,6 +137,11 @@
         request.put("Short", true);
         request.put("CaseSensitive", caseSensitive);
 
+        if (hasPaging) {
+            request.put("Since", since);
+            request.put("Limit", limit);
+        }
+
         switch (type) {
             case PATIENT:
                 request.put("Level", "Patient");
@@ -163,6 +171,21 @@
         return result;
     }
 
+    public static List<OrthancResource> find(IOrthancConnection connection,
+                                             ResourceType type,
+                                             Map<String, String> tags,
+                                             boolean caseSensitive,
+                                             int since,
+                                             int limit) {
+        return find(connection, type, tags, caseSensitive, true, since, limit);
+    }
+
+    public static List<OrthancResource> find(IOrthancConnection connection,
+                                             ResourceType type,
+                                             Map<String, String> tags,
+                                             boolean caseSensitive) {
+        return find(connection, type, tags, caseSensitive, false, 0, 0);
+    }
 
     public Patient getFhirPatient() {
         if (type != ResourceType.PATIENT) {