changeset 30:296798e75896

publish software name and version in FHIR /metadata
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Jun 2024 20:43:37 +0200
parents 118adbad648f
children 7579255a14f8
files Samples/FHIR/pom.xml Samples/FHIR/src/main/java/ImagingStudyProvider.java Samples/FHIR/src/main/java/Main.java Samples/FHIR/src/main/java/Toolbox.java
diffstat 4 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Samples/FHIR/pom.xml	Wed Jun 12 14:44:37 2024 +0200
+++ b/Samples/FHIR/pom.xml	Wed Jun 12 20:43:37 2024 +0200
@@ -68,6 +68,7 @@
         <version>1.0.0</version>
         <executions>
           <execution>
+            <id>execution1</id>
             <phase>initialize</phase>
             <goals>
               <goal>read-project-properties</goal>
@@ -78,9 +79,20 @@
               </files>
             </configuration>
           </execution>
+
+          <!-- Write the properties as a resource that can be accessed from Java code -->
+          <execution>
+            <id>execution2</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>write-project-properties</goal>
+            </goals>
+            <configuration>
+              <outputFile>${project.build.outputDirectory}/app.properties</outputFile>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
-
     </plugins>
   </build>
 
--- a/Samples/FHIR/src/main/java/ImagingStudyProvider.java	Wed Jun 12 14:44:37 2024 +0200
+++ b/Samples/FHIR/src/main/java/ImagingStudyProvider.java	Wed Jun 12 20:43:37 2024 +0200
@@ -29,7 +29,6 @@
 import ca.uhn.fhir.rest.server.IResourceProvider;
 import org.hl7.fhir.r5.model.IdType;
 import org.hl7.fhir.r5.model.ImagingStudy;
-import org.hl7.fhir.r5.model.Patient;
 
 import java.util.ArrayList;
 import java.util.HashMap;
--- a/Samples/FHIR/src/main/java/Main.java	Wed Jun 12 14:44:37 2024 +0200
+++ b/Samples/FHIR/src/main/java/Main.java	Wed Jun 12 20:43:37 2024 +0200
@@ -23,20 +23,18 @@
 
 
 import be.uclouvain.orthanc.Callbacks;
-import be.uclouvain.orthanc.Functions;
 
 import ca.uhn.fhir.context.FhirContext;
 import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
 import ca.uhn.fhir.rest.server.IResourceProvider;
 import ca.uhn.fhir.rest.server.RestfulServer;
-import org.json.JSONArray;
-import org.json.JSONObject;
 import org.springframework.mock.web.MockServletConfig;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Properties;
 import javax.servlet.ServletException;
 
 
@@ -44,6 +42,16 @@
     Main() throws ServletException {
         setFhirContext(FhirContext.forR5());
 
+        setServerName("Orthanc FHIR server");
+
+        try (InputStream is = Main.class.getResourceAsStream("app.properties")) {
+            Properties properties = new Properties();
+            properties.load(is);
+            setServerVersion(properties.getProperty("orthanc_java.version"));
+        } catch (IOException e) {
+            // Ignore error
+        }
+
         FhirConfiguration configuration = new FhirConfiguration();
         setServerAddressStrategy(new HardcodedServerAddressStrategy(configuration.getServerBaseUrl()));
 
--- a/Samples/FHIR/src/main/java/Toolbox.java	Wed Jun 12 14:44:37 2024 +0200
+++ b/Samples/FHIR/src/main/java/Toolbox.java	Wed Jun 12 20:43:37 2024 +0200
@@ -25,7 +25,6 @@
 import org.hl7.fhir.r5.model.CodeableConcept;
 import org.hl7.fhir.r5.model.Reference;
 
-import java.time.LocalDate;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;