Mercurial > hg > orthanc
comparison OrthancServer/ServerJobs/ResourceModificationJob.cpp @ 2825:8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Sep 2018 15:24:01 +0200 |
parents | a21b244efb37 |
children | ff0ed5ea9e4e |
comparison
equal
deleted
inserted
replaced
2824:0e1b79bc4a2d | 2825:8aa6aef11b70 |
---|---|
127 } | 127 } |
128 | 128 |
129 | 129 |
130 LOG(INFO) << "Modifying instance in a job: " << instance; | 130 LOG(INFO) << "Modifying instance in a job: " << instance; |
131 | 131 |
132 std::auto_ptr<ServerContext::DicomCacheLocker> locker; | 132 |
133 /** | |
134 * Retrieve the original instance from the DICOM cache. | |
135 **/ | |
136 | |
137 std::auto_ptr<DicomInstanceHasher> originalHasher; | |
138 std::auto_ptr<ParsedDicomFile> modified; | |
133 | 139 |
134 try | 140 try |
135 { | 141 { |
136 locker.reset(new ServerContext::DicomCacheLocker(context_, instance)); | 142 ServerContext::DicomCacheLocker locker(context_, instance); |
143 ParsedDicomFile& original = locker.GetDicom(); | |
144 | |
145 originalHasher.reset(new DicomInstanceHasher(original.GetHasher())); | |
146 modified.reset(original.Clone(true)); | |
137 } | 147 } |
138 catch (OrthancException&) | 148 catch (OrthancException&) |
139 { | 149 { |
140 LOG(WARNING) << "An instance was removed after the job was issued: " << instance; | 150 LOG(WARNING) << "An instance was removed after the job was issued: " << instance; |
141 return false; | 151 return false; |
142 } | 152 } |
143 | |
144 | |
145 ParsedDicomFile& original = locker->GetDicom(); | |
146 DicomInstanceHasher originalHasher = original.GetHasher(); | |
147 | 153 |
148 | 154 |
149 /** | 155 /** |
150 * Compute the resulting DICOM instance. | 156 * Compute the resulting DICOM instance. |
151 **/ | 157 **/ |
152 | 158 |
153 std::auto_ptr<ParsedDicomFile> modified(original.Clone(true)); | |
154 modification_->Apply(*modified); | 159 modification_->Apply(*modified); |
155 | 160 |
156 DicomInstanceToStore toStore; | 161 DicomInstanceToStore toStore; |
157 toStore.SetOrigin(origin_); | 162 toStore.SetOrigin(origin_); |
158 toStore.SetParsedDicomFile(*modified); | 163 toStore.SetParsedDicomFile(*modified); |
167 | 172 |
168 MetadataType metadataType = (isAnonymization_ ? | 173 MetadataType metadataType = (isAnonymization_ ? |
169 MetadataType_AnonymizedFrom : | 174 MetadataType_AnonymizedFrom : |
170 MetadataType_ModifiedFrom); | 175 MetadataType_ModifiedFrom); |
171 | 176 |
172 if (originalHasher.HashSeries() != modifiedHasher.HashSeries()) | 177 if (originalHasher->HashSeries() != modifiedHasher.HashSeries()) |
173 { | 178 { |
174 toStore.AddMetadata(ResourceType_Series, metadataType, originalHasher.HashSeries()); | 179 toStore.AddMetadata(ResourceType_Series, metadataType, originalHasher->HashSeries()); |
175 } | 180 } |
176 | 181 |
177 if (originalHasher.HashStudy() != modifiedHasher.HashStudy()) | 182 if (originalHasher->HashStudy() != modifiedHasher.HashStudy()) |
178 { | 183 { |
179 toStore.AddMetadata(ResourceType_Study, metadataType, originalHasher.HashStudy()); | 184 toStore.AddMetadata(ResourceType_Study, metadataType, originalHasher->HashStudy()); |
180 } | 185 } |
181 | 186 |
182 if (originalHasher.HashPatient() != modifiedHasher.HashPatient()) | 187 if (originalHasher->HashPatient() != modifiedHasher.HashPatient()) |
183 { | 188 { |
184 toStore.AddMetadata(ResourceType_Patient, metadataType, originalHasher.HashPatient()); | 189 toStore.AddMetadata(ResourceType_Patient, metadataType, originalHasher->HashPatient()); |
185 } | 190 } |
186 | 191 |
187 assert(instance == originalHasher.HashInstance()); | 192 assert(instance == originalHasher->HashInstance()); |
188 toStore.AddMetadata(ResourceType_Instance, metadataType, instance); | 193 toStore.AddMetadata(ResourceType_Instance, metadataType, instance); |
189 | 194 |
190 | 195 |
191 /** | 196 /** |
192 * Store the resulting DICOM instance into the Orthanc store. | 197 * Store the resulting DICOM instance into the Orthanc store. |