Mercurial > hg > orthanc-java
comparison Samples/FHIR/src/main/java/ImagingStudyProvider.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 | 1c407ba1d311 |
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 * |
20 * You should have received a copy of the GNU General Public License | 20 * You should have received a copy of the GNU General Public License |
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 **/ | 22 **/ |
23 | 23 |
24 | 24 |
25 import ca.uhn.fhir.rest.annotation.IdParam; | 25 import be.uclouvain.orthanc.ResourceType; |
26 import ca.uhn.fhir.rest.annotation.OptionalParam; | 26 import ca.uhn.fhir.rest.annotation.*; |
27 import ca.uhn.fhir.rest.annotation.Read; | |
28 import ca.uhn.fhir.rest.annotation.Search; | |
29 import ca.uhn.fhir.rest.param.ReferenceParam; | 27 import ca.uhn.fhir.rest.param.ReferenceParam; |
30 import ca.uhn.fhir.rest.param.StringParam; | 28 import ca.uhn.fhir.rest.param.StringParam; |
31 import ca.uhn.fhir.rest.server.IResourceProvider; | 29 import ca.uhn.fhir.rest.server.IResourceProvider; |
32 import org.hl7.fhir.r5.model.IdType; | 30 import org.hl7.fhir.r5.model.IdType; |
33 import org.hl7.fhir.r5.model.ImagingStudy; | 31 import org.hl7.fhir.r5.model.ImagingStudy; |
65 } | 63 } |
66 } | 64 } |
67 | 65 |
68 @Search() | 66 @Search() |
69 public List<ImagingStudy> getImagingStudies(@OptionalParam(name = ImagingStudy.SP_IDENTIFIER) StringParam theIdentifier, | 67 public List<ImagingStudy> getImagingStudies(@OptionalParam(name = ImagingStudy.SP_IDENTIFIER) StringParam theIdentifier, |
70 @OptionalParam(name = ImagingStudy.SP_SUBJECT) ReferenceParam theSubject) { | 68 @OptionalParam(name = ImagingStudy.SP_SUBJECT) ReferenceParam theSubject, |
69 @Offset Integer theOffset, | |
70 @Count Integer theCount) { | |
71 Map<String, String> tags = new HashMap<>(); | 71 Map<String, String> tags = new HashMap<>(); |
72 | 72 |
73 if (theIdentifier != null) { | 73 if (theIdentifier != null) { |
74 tags.put(Toolbox.TAG_STUDY_INSTANCE_UID, theIdentifier.getValue()); | 74 tags.put(Toolbox.TAG_STUDY_INSTANCE_UID, theIdentifier.getValue()); |
75 } | 75 } |
77 if (theSubject != null) { | 77 if (theSubject != null) { |
78 // https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html#search-parameters-resource-reference | 78 // https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html#search-parameters-resource-reference |
79 tags.put(Toolbox.TAG_PATIENT_ID, theSubject.getValue()); | 79 tags.put(Toolbox.TAG_PATIENT_ID, theSubject.getValue()); |
80 } | 80 } |
81 | 81 |
82 List<OrthancResource> resources = OrthancResource.find(orthanc, be.uclouvain.orthanc.ResourceType.STUDY, tags, false); | 82 final boolean caseSensitive = false; |
83 | |
84 List<OrthancResource> resources; | |
85 | |
86 if (theOffset != null && | |
87 theCount != null) { | |
88 resources = OrthancResource.find(orthanc, ResourceType.STUDY, tags, caseSensitive, theOffset.intValue(), theCount.intValue()); | |
89 } else if (theCount != null) { | |
90 resources = OrthancResource.find(orthanc, ResourceType.STUDY, tags, caseSensitive, 0, theCount.intValue()); | |
91 } else { | |
92 resources = OrthancResource.find(orthanc, ResourceType.STUDY, tags, false); | |
93 } | |
83 | 94 |
84 List<ImagingStudy> studies = new ArrayList<>(); | 95 List<ImagingStudy> studies = new ArrayList<>(); |
85 for (OrthancResource resource : resources) { | 96 for (OrthancResource resource : resources) { |
86 ImagingStudy study = resource.getFhirStudy(orthanc); | 97 ImagingStudy study = resource.getFhirStudy(orthanc); |
87 if (study.hasId()) { | 98 if (study.hasId()) { |