# HG changeset patch
# User Sebastien Jodogne <s.jodogne@gmail.com>
# Date 1544717990 -3600
# Node ID 750de70b3603edf53e6309cdf2fcceb48ce1dd47
# Parent  45a4a1571b4eb83a98e96fbd6655c7f8716834ca
make "/tools/create-dicom" more tolerant to invalid specific character set

diff -r 45a4a1571b4e -r 750de70b3603 NEWS
--- a/NEWS	Thu Dec 13 15:14:39 2018 +0100
+++ b/NEWS	Thu Dec 13 17:19:50 2018 +0100
@@ -2,6 +2,13 @@
 ===============================
 
 
+Maintenance
+-----------
+
+* "/tools/create-dicom" is more tolerant to invalid specific character set
+
+
+
 Version 1.5.0 (2018-12-10)
 ==========================
 
diff -r 45a4a1571b4e -r 750de70b3603 OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp
--- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Thu Dec 13 15:14:39 2018 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Thu Dec 13 17:19:50 2018 +0100
@@ -440,6 +440,7 @@
       // Select one existing child instance of the parent resource, to
       // retrieve all its tags
       Json::Value siblingTags;
+      std::string siblingInstanceId;
 
       {
         // Retrieve all the instances of the parent resource
@@ -452,7 +453,8 @@
           throw OrthancException(ErrorCode_InternalError);
         }
 
-        context.ReadDicomAsJson(siblingTags, siblingInstances.front());
+        siblingInstanceId = siblingInstances.front();
+        context.ReadDicomAsJson(siblingTags, siblingInstanceId);
       }
 
 
@@ -463,11 +465,14 @@
         if (siblingTags.isMember(SPECIFIC_CHARACTER_SET))
         {
           Encoding encoding;
+
           if (!siblingTags[SPECIFIC_CHARACTER_SET].isMember("Value") ||
               siblingTags[SPECIFIC_CHARACTER_SET]["Value"].type() != Json::stringValue ||
               !GetDicomEncoding(encoding, siblingTags[SPECIFIC_CHARACTER_SET]["Value"].asCString()))
           {
-            throw OrthancException(ErrorCode_CreateDicomParentEncoding);
+            LOG(WARNING) << "Instance with an incorrect Specific Character Set, "
+                         << "using the default Orthanc encoding: " << siblingInstanceId;
+            encoding = GetDefaultDicomEncoding();
           }
 
           dicom.SetEncoding(encoding);