changeset 3507:69e49fc044f8

Fix generation of "SOP Instance UID" on split and merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Aug 2019 16:54:00 +0200
parents d2b9981017c4
children 70524b4acc72
files NEWS OrthancServer/ServerJobs/MergeStudyJob.cpp OrthancServer/ServerJobs/SplitStudyJob.cpp Plugins/Engine/OrthancPlugins.cpp
diffstat 4 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Aug 28 15:19:04 2019 +0200
+++ b/NEWS	Wed Aug 28 16:54:00 2019 +0200
@@ -7,6 +7,7 @@
 * Security: If remote access is enabled, HTTP authentication is also enabled by default
 * Log an explicit error if uploading an empty DICOM file using REST API
 * Fix compatibility of LSB binaries with Ubuntu >= 18.04
+* Fix generation of "SOP Instance UID" on split and merge
 
 
 Version 1.5.7 (2019-06-25)
--- a/OrthancServer/ServerJobs/MergeStudyJob.cpp	Wed Aug 28 15:19:04 2019 +0200
+++ b/OrthancServer/ServerJobs/MergeStudyJob.cpp	Wed Aug 28 16:54:00 2019 +0200
@@ -137,6 +137,9 @@
     
     modified->ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, targetSeriesUid->second);
 
+    // Fix since Orthanc 1.5.8: Assign new "SOPInstanceUID", as the instance has been modified
+    modified->ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance));
+
     DicomInstanceToStore toStore;
     toStore.SetOrigin(origin_);
     toStore.SetParsedDicomFile(*modified);
--- a/OrthancServer/ServerJobs/SplitStudyJob.cpp	Wed Aug 28 15:19:04 2019 +0200
+++ b/OrthancServer/ServerJobs/SplitStudyJob.cpp	Wed Aug 28 16:54:00 2019 +0200
@@ -125,6 +125,9 @@
     modified->ReplacePlainString(DICOM_TAG_STUDY_INSTANCE_UID, targetStudyUid_);
     modified->ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, targetSeriesUid->second);
 
+    // Fix since Orthanc 1.5.8: Assign new "SOPInstanceUID", as the instance has been modified
+    modified->ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance));
+
     if (targetStudy_.empty())
     {
       targetStudy_ = modified->GetHasher().HashStudy();
--- a/Plugins/Engine/OrthancPlugins.cpp	Wed Aug 28 15:19:04 2019 +0200
+++ b/Plugins/Engine/OrthancPlugins.cpp	Wed Aug 28 16:54:00 2019 +0200
@@ -2113,6 +2113,12 @@
     }
     else
     {
+      if (result.size() > 1)
+      {
+        LOG(WARNING) << "LookupResource(): Multiple resources match the query (instead of 0 or 1), which indicates "
+                     << "your DICOM database breaks the DICOM model of the real world";
+      }
+      
       throw OrthancException(ErrorCode_UnknownResource);
     }
   }