Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 1002:b067017a8a5b lua-scripting
anonymization refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Jul 2014 16:31:14 +0200 |
parents | 2f76b92addd4 |
children | 84b6d7bca6db |
comparison
equal
deleted
inserted
replaced
1001:f3929718ea7e | 1002:b067017a8a5b |
---|---|
250 ParsedDicomFile& original = locker->GetDicom(); | 250 ParsedDicomFile& original = locker->GetDicom(); |
251 DicomInstanceHasher originalHasher = original.GetHasher(); | 251 DicomInstanceHasher originalHasher = original.GetHasher(); |
252 | 252 |
253 | 253 |
254 /** | 254 /** |
255 * Compute the resulting DICOM instance and store it into the Orthanc store. | 255 * Compute the resulting DICOM instance. |
256 **/ | 256 **/ |
257 | 257 |
258 std::auto_ptr<ParsedDicomFile> modified(original.Clone()); | 258 std::auto_ptr<ParsedDicomFile> modified(original.Clone()); |
259 modification.Apply(*modified); | 259 modification.Apply(*modified); |
260 | 260 |
261 | |
262 /** | |
263 * Prepare the metadata information to associate with the | |
264 * resulting DICOM instance (AnonymizedFrom/ModifiedFrom). | |
265 **/ | |
266 | |
267 DicomInstanceHasher modifiedHasher = modified->GetHasher(); | |
268 ServerIndex::MetadataMap metadata; | |
269 | |
270 if (originalHasher.HashSeries() != modifiedHasher.HashSeries()) | |
271 { | |
272 metadata[std::make_pair(ResourceType_Series, metadataType)] = originalHasher.HashSeries(); | |
273 } | |
274 | |
275 if (originalHasher.HashStudy() != modifiedHasher.HashStudy()) | |
276 { | |
277 metadata[std::make_pair(ResourceType_Study, metadataType)] = originalHasher.HashStudy(); | |
278 } | |
279 | |
280 if (originalHasher.HashPatient() != modifiedHasher.HashPatient()) | |
281 { | |
282 metadata[std::make_pair(ResourceType_Patient, metadataType)] = originalHasher.HashPatient(); | |
283 } | |
284 | |
285 assert(*it == originalHasher.HashInstance()); | |
286 metadata[std::make_pair(ResourceType_Instance, metadataType)] = *it; | |
287 | |
288 | |
289 /** | |
290 * Store the resulting DICOM instance into the Orthanc store. | |
291 **/ | |
292 | |
261 std::string modifiedInstance; | 293 std::string modifiedInstance; |
262 if (context.Store(modifiedInstance, *modified) != StoreStatus_Success) | 294 if (context.Store(modifiedInstance, *modified, metadata) != StoreStatus_Success) |
263 { | 295 { |
264 LOG(ERROR) << "Error while storing a modified instance " << *it; | 296 LOG(ERROR) << "Error while storing a modified instance " << *it; |
265 return; | 297 return; |
266 } | 298 } |
267 | 299 |
268 | 300 // Sanity checks in debug mode |
269 /** | |
270 * Record metadata information (AnonymizedFrom/ModifiedFrom). | |
271 **/ | |
272 | |
273 DicomInstanceHasher modifiedHasher = modified->GetHasher(); | |
274 | |
275 if (originalHasher.HashSeries() != modifiedHasher.HashSeries()) | |
276 { | |
277 context.GetIndex().SetMetadata(modifiedHasher.HashSeries(), | |
278 metadataType, originalHasher.HashSeries()); | |
279 } | |
280 | |
281 if (originalHasher.HashStudy() != modifiedHasher.HashStudy()) | |
282 { | |
283 context.GetIndex().SetMetadata(modifiedHasher.HashStudy(), | |
284 metadataType, originalHasher.HashStudy()); | |
285 } | |
286 | |
287 if (originalHasher.HashPatient() != modifiedHasher.HashPatient()) | |
288 { | |
289 context.GetIndex().SetMetadata(modifiedHasher.HashPatient(), | |
290 metadataType, originalHasher.HashPatient()); | |
291 } | |
292 | |
293 assert(*it == originalHasher.HashInstance()); | |
294 assert(modifiedInstance == modifiedHasher.HashInstance()); | 301 assert(modifiedInstance == modifiedHasher.HashInstance()); |
295 context.GetIndex().SetMetadata(modifiedInstance, metadataType, *it); | |
296 | 302 |
297 | 303 |
298 /** | 304 /** |
299 * Compute the JSON object that is returned by the REST call. | 305 * Compute the JSON object that is returned by the REST call. |
300 **/ | 306 **/ |