Mercurial > hg > orthanc-java
comparison Samples/FHIR/src/main/java/EndpointProvider.java @ 11:8d876a4f541b
added sample FHIR server
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 21 Oct 2023 09:53:25 +0200 |
parents | |
children | 0dc05fe76bd5 |
comparison
equal
deleted
inserted
replaced
10:6b9433432ee0 | 11:8d876a4f541b |
---|---|
1 /** | |
2 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium | |
3 * SPDX-License-Identifier: GPL-3.0-or-later | |
4 */ | |
5 | |
6 /** | |
7 * Java plugin for Orthanc | |
8 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium | |
9 * | |
10 * This program is free software: you can redistribute it and/or | |
11 * modify it under the terms of the GNU General Public License as | |
12 * published by the Free Software Foundation, either version 3 of the | |
13 * License, or (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, but | |
16 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 * General Public License for more details. | |
19 * | |
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/>. | |
22 **/ | |
23 | |
24 | |
25 import ca.uhn.fhir.rest.annotation.IdParam; | |
26 import ca.uhn.fhir.rest.annotation.Read; | |
27 import ca.uhn.fhir.rest.annotation.Search; | |
28 import ca.uhn.fhir.rest.server.IResourceProvider; | |
29 import org.hl7.fhir.r5.model.Endpoint; | |
30 import org.hl7.fhir.r5.model.IdType; | |
31 | |
32 import java.util.ArrayList; | |
33 import java.util.List; | |
34 | |
35 public class EndpointProvider implements IResourceProvider { | |
36 public static final String ID = "wado-rs"; | |
37 private IOrthancConnection orthanc; | |
38 private FhirConfiguration configuration; | |
39 | |
40 EndpointProvider(IOrthancConnection orthanc) { | |
41 this.orthanc = orthanc; | |
42 this.configuration = new FhirConfiguration(); | |
43 } | |
44 | |
45 private Endpoint createEndpoint() { | |
46 Endpoint endpoint = new Endpoint(); | |
47 | |
48 // https://build.fhir.org/endpoint-example-wadors.json.html | |
49 | |
50 endpoint.setAddress(configuration.getDicomWebBaseUrl()); | |
51 endpoint.setId(ID); | |
52 endpoint.setStatus(Endpoint.EndpointStatus.ACTIVE); | |
53 endpoint.addConnectionType(Toolbox.createCodeableConcept("http://terminology.hl7.org/CodeSystem/endpoint-connection-type", "dicom-wado-rs")); | |
54 endpoint.setName("Orthanc DICOMweb server"); | |
55 | |
56 return endpoint; | |
57 } | |
58 | |
59 @Override | |
60 public Class<Endpoint> getResourceType() { | |
61 return Endpoint.class; | |
62 } | |
63 | |
64 @Read() | |
65 public Endpoint getResourceById(@IdParam IdType theId) { | |
66 if (theId.getIdPart().equals(ID) && | |
67 IOrthancConnection.hasPluginInstalled(orthanc, "dicom-web")) { | |
68 return createEndpoint(); | |
69 } else { | |
70 return null; | |
71 } | |
72 } | |
73 | |
74 @Search() | |
75 public List<Endpoint> getEndpoints() { | |
76 List<Endpoint> endpoints = new ArrayList<>(); | |
77 | |
78 if (IOrthancConnection.hasPluginInstalled(orthanc, "dicom-web")) { | |
79 endpoints.add(createEndpoint()); | |
80 } | |
81 | |
82 return endpoints; | |
83 } | |
84 } |