comparison 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
comparison
equal deleted inserted replaced
13:d7a55838d821 14:0dc05fe76bd5
1 /** 1 /**
2 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium 2 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
3 * SPDX-License-Identifier: GPL-3.0-or-later 3 * SPDX-License-Identifier: GPL-3.0-or-later
4 */ 4 **/
5 5
6 /** 6 /**
7 * Java plugin for Orthanc 7 * Java plugin for Orthanc
8 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium 8 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium
9 * 9 *
117 } else { 117 } else {
118 return children; 118 return children;
119 } 119 }
120 } 120 }
121 121
122 public static List<OrthancResource> find(IOrthancConnection connection, 122 private static List<OrthancResource> find(IOrthancConnection connection,
123 ResourceType type, 123 ResourceType type,
124 Map<String, String> tags, 124 Map<String, String> tags,
125 boolean caseSensitive) { 125 boolean caseSensitive,
126 boolean hasPaging,
127 int since,
128 int limit) {
126 JSONObject query = new JSONObject(); 129 JSONObject query = new JSONObject();
127 for (Map.Entry<String, String> entry : tags.entrySet()) { 130 for (Map.Entry<String, String> entry : tags.entrySet()) {
128 query.put(entry.getKey(), entry.getValue()); 131 query.put(entry.getKey(), entry.getValue());
129 } 132 }
130 133
131 JSONObject request = new JSONObject(); 134 JSONObject request = new JSONObject();
132 request.put("Expand", true); 135 request.put("Expand", true);
133 request.put("Query", query); 136 request.put("Query", query);
134 request.put("Short", true); 137 request.put("Short", true);
135 request.put("CaseSensitive", caseSensitive); 138 request.put("CaseSensitive", caseSensitive);
139
140 if (hasPaging) {
141 request.put("Since", since);
142 request.put("Limit", limit);
143 }
136 144
137 switch (type) { 145 switch (type) {
138 case PATIENT: 146 case PATIENT:
139 request.put("Level", "Patient"); 147 request.put("Level", "Patient");
140 break; 148 break;
161 } 169 }
162 170
163 return result; 171 return result;
164 } 172 }
165 173
174 public static List<OrthancResource> find(IOrthancConnection connection,
175 ResourceType type,
176 Map<String, String> tags,
177 boolean caseSensitive,
178 int since,
179 int limit) {
180 return find(connection, type, tags, caseSensitive, true, since, limit);
181 }
182
183 public static List<OrthancResource> find(IOrthancConnection connection,
184 ResourceType type,
185 Map<String, String> tags,
186 boolean caseSensitive) {
187 return find(connection, type, tags, caseSensitive, false, 0, 0);
188 }
166 189
167 public Patient getFhirPatient() { 190 public Patient getFhirPatient() {
168 if (type != ResourceType.PATIENT) { 191 if (type != ResourceType.PATIENT) {
169 throw new RuntimeException("Not a patient"); 192 throw new RuntimeException("Not a patient");
170 } 193 }