changeset 15:b69bc09e2969

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Oct 2023 13:51:32 +0200
parents 0dc05fe76bd5
children 1be232fa8f33
files Samples/Dcm4Che/src/main/java/Main.java Samples/FHIR/src/main/java/OrthancResource.java Samples/FHIR/src/main/java/Toolbox.java
diffstat 3 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Samples/Dcm4Che/src/main/java/Main.java	Sat Oct 21 16:41:59 2023 +0200
+++ b/Samples/Dcm4Che/src/main/java/Main.java	Thu Oct 26 13:51:32 2023 +0200
@@ -45,7 +45,7 @@
                              Map<String, String> getParameters,
                              byte[] body) {
                 if (method != HttpMethod.POST) {
-                    output.sendMethodNotAllowed("POST");
+                    output.sendMethodNotAllowed("POST");  // Answer with HTTP status 405
                 } else {
                     ByteArrayInputStream stream = new ByteArrayInputStream(body);
 
--- a/Samples/FHIR/src/main/java/OrthancResource.java	Sat Oct 21 16:41:59 2023 +0200
+++ b/Samples/FHIR/src/main/java/OrthancResource.java	Thu Oct 26 13:51:32 2023 +0200
@@ -197,7 +197,11 @@
 
         String birthDate = getTags().getOrDefault(Toolbox.TAG_PATIENT_BIRTH_DATE, "");
         if (birthDate != null) {
-            patient.setBirthDate(Toolbox.parseDicomDate(birthDate));
+            try {
+                patient.setBirthDate(Toolbox.parseDicomDate(birthDate));
+            } catch (IllegalArgumentException e) {
+                // Ignore incorrect dates
+            }
         }
 
         String patientName = getTags().getOrDefault(Toolbox.TAG_PATIENT_NAME, "");
@@ -248,7 +252,16 @@
 
         String studyDate = getTags().getOrDefault(Toolbox.TAG_STUDY_DATE, "");
         if (!studyDate.isEmpty()) {
-            study.setStarted(Toolbox.parseDicomDate(studyDate));
+            try {
+                study.setStarted(Toolbox.parseDicomDate(studyDate));
+            } catch (IllegalArgumentException e) {
+                // Ignore incorrect dates
+            }
+        }
+
+        String studyDescription = getTags().getOrDefault(Toolbox.TAG_STUDY_DESCRIPTION, "");
+        if (!studyDescription.isEmpty()) {
+            study.setDescription(studyDescription);
         }
 
         study.addIdentifier();
--- a/Samples/FHIR/src/main/java/Toolbox.java	Sat Oct 21 16:41:59 2023 +0200
+++ b/Samples/FHIR/src/main/java/Toolbox.java	Thu Oct 26 13:51:32 2023 +0200
@@ -45,6 +45,7 @@
     public static String TAG_SERIES_NUMBER = "0020,0011";
     public static String TAG_SOP_INSTANCE_UID = "0008,0018";
     public static String TAG_INSTANCE_NUMBER = "0020,0013";
+    public static String TAG_STUDY_DESCRIPTION = "0008,1030";
 
     public static Date parseDicomDate(String date) {
         Pattern pattern = Pattern.compile("^([0-9]{4})([0-9]{2})([0-9]{2})$");