comparison OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp @ 4508:8f9090b137f1

Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 11 Feb 2021 11:00:05 +0100
parents d9473bd5ed43
children 45bce660ce3a
comparison
equal deleted inserted replaced
4507:b4c58795f3a8 4508:8f9090b137f1
208 } 208 }
209 } 209 }
210 210
211 assert(modifiedUid == IDicomTranscoder::GetSopInstanceUid(modified->GetDcmtkObject())); 211 assert(modifiedUid == IDicomTranscoder::GetSopInstanceUid(modified->GetDcmtkObject()));
212 212
213 DicomInstanceToStore toStore; 213 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(*modified));
214 toStore.SetOrigin(origin_); 214 toStore->SetOrigin(origin_);
215 toStore.SetParsedDicomFile(*modified);
216 215
217 216
218 /** 217 /**
219 * Prepare the metadata information to associate with the 218 * Prepare the metadata information to associate with the
220 * resulting DICOM instance (AnonymizedFrom/ModifiedFrom). 219 * resulting DICOM instance (AnonymizedFrom/ModifiedFrom).
226 MetadataType_AnonymizedFrom : 225 MetadataType_AnonymizedFrom :
227 MetadataType_ModifiedFrom); 226 MetadataType_ModifiedFrom);
228 227
229 if (originalHasher->HashSeries() != modifiedHasher.HashSeries()) 228 if (originalHasher->HashSeries() != modifiedHasher.HashSeries())
230 { 229 {
231 toStore.AddMetadata(ResourceType_Series, metadataType, originalHasher->HashSeries()); 230 toStore->AddMetadata(ResourceType_Series, metadataType, originalHasher->HashSeries());
232 } 231 }
233 232
234 if (originalHasher->HashStudy() != modifiedHasher.HashStudy()) 233 if (originalHasher->HashStudy() != modifiedHasher.HashStudy())
235 { 234 {
236 toStore.AddMetadata(ResourceType_Study, metadataType, originalHasher->HashStudy()); 235 toStore->AddMetadata(ResourceType_Study, metadataType, originalHasher->HashStudy());
237 } 236 }
238 237
239 if (originalHasher->HashPatient() != modifiedHasher.HashPatient()) 238 if (originalHasher->HashPatient() != modifiedHasher.HashPatient())
240 { 239 {
241 toStore.AddMetadata(ResourceType_Patient, metadataType, originalHasher->HashPatient()); 240 toStore->AddMetadata(ResourceType_Patient, metadataType, originalHasher->HashPatient());
242 } 241 }
243 242
244 assert(instance == originalHasher->HashInstance()); 243 assert(instance == originalHasher->HashInstance());
245 toStore.AddMetadata(ResourceType_Instance, metadataType, instance); 244 toStore->AddMetadata(ResourceType_Instance, metadataType, instance);
246 245
247 246
248 /** 247 /**
249 * Store the resulting DICOM instance into the Orthanc store. 248 * Store the resulting DICOM instance into the Orthanc store.
250 **/ 249 **/
251 250
252 std::string modifiedInstance; 251 std::string modifiedInstance;
253 if (GetContext().Store(modifiedInstance, toStore, 252 if (GetContext().Store(modifiedInstance, *toStore,
254 StoreInstanceMode_Default) != StoreStatus_Success) 253 StoreInstanceMode_Default) != StoreStatus_Success)
255 { 254 {
256 throw OrthancException(ErrorCode_CannotStoreInstance, 255 throw OrthancException(ErrorCode_CannotStoreInstance,
257 "Error while storing a modified instance " + instance); 256 "Error while storing a modified instance " + instance);
258 } 257 }