diff OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 2899:5dd649de253d

POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 Oct 2018 12:03:51 +0200
parents 2bd87764709c
children 4b3929668358
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Thu Oct 18 11:44:17 2018 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Thu Oct 18 12:03:51 2018 +0200
@@ -208,7 +208,8 @@
 
   static void StoreCreatedInstance(std::string& id /* out */,
                                    RestApiPostCall& call,
-                                   ParsedDicomFile& dicom)
+                                   ParsedDicomFile& dicom,
+                                   bool sendAnswer)
   {
     DicomInstanceToStore toStore;
     toStore.SetOrigin(DicomInstanceOrigin::FromRest(call));
@@ -221,6 +222,11 @@
     {
       throw OrthancException(ErrorCode_CannotStoreInstance);
     }
+
+    if (sendAnswer)
+    {
+      OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status);
+    }
   }
 
 
@@ -356,7 +362,7 @@
         dicom->ReplacePlainString(DICOM_TAG_INSTANCE_NUMBER, boost::lexical_cast<std::string>(i + 1));
         dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1));
 
-        StoreCreatedInstance(someInstance, call, *dicom);
+        StoreCreatedInstance(someInstance, call, *dicom, false);
       }
     }
     catch (OrthancException&)
@@ -583,10 +589,7 @@
     }
 
     std::string id;
-    StoreCreatedInstance(id, call, dicom);
-    OrthancRestApi::GetApi(call).AnswerStoredResource(call, id, ResourceType_Instance, StoreStatus_Success);
-
-    return;
+    StoreCreatedInstance(id, call, dicom, true);
   }
 
 
@@ -610,8 +613,7 @@
       CreateDicomV1(dicom, call, request);
 
       std::string id;
-      StoreCreatedInstance(id, call, dicom);
-      OrthancRestApi::GetApi(call).AnswerStoredResource(call, id, ResourceType_Instance, StoreStatus_Success);
+      StoreCreatedInstance(id, call, dicom, true);
     }
   }