Mercurial > hg > orthanc
comparison OrthancServer/ServerToolbox.cpp @ 2120:4b02ec79728a
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Nov 2016 11:19:19 +0100 |
parents | b1291df2f780 |
children | 7e8889bc95c6 |
comparison
equal
deleted
inserted
replaced
2119:e0517f25919e | 2120:4b02ec79728a |
---|---|
42 | 42 |
43 #include <cassert> | 43 #include <cassert> |
44 | 44 |
45 namespace Orthanc | 45 namespace Orthanc |
46 { | 46 { |
47 namespace Toolbox | 47 namespace ServerToolbox |
48 { | 48 { |
49 void SimplifyTags(Json::Value& target, | 49 void SimplifyTags(Json::Value& target, |
50 const Json::Value& source, | 50 const Json::Value& source, |
51 DicomToJsonFormat format) | 51 DicomToJsonFormat format) |
52 { | 52 { |
187 LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t; | 187 LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t; |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 | 191 |
192 static void SetMainDicomTagsInternal(IDatabaseWrapper& database, | 192 static void StoreMainDicomTagsInternal(IDatabaseWrapper& database, |
193 int64_t resource, | 193 int64_t resource, |
194 const DicomMap& tags) | 194 const DicomMap& tags) |
195 { | 195 { |
196 DicomArray flattened(tags); | 196 DicomArray flattened(tags); |
197 | 197 |
198 for (size_t i = 0; i < flattened.GetSize(); i++) | 198 for (size_t i = 0; i < flattened.GetSize(); i++) |
199 { | 199 { |
207 } | 207 } |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 | 211 |
212 void SetMainDicomTags(IDatabaseWrapper& database, | 212 void StoreMainDicomTags(IDatabaseWrapper& database, |
213 int64_t resource, | 213 int64_t resource, |
214 ResourceType level, | 214 ResourceType level, |
215 const DicomMap& dicomSummary) | 215 const DicomMap& dicomSummary) |
216 { | 216 { |
217 // WARNING: The database should be locked with a transaction! | 217 // WARNING: The database should be locked with a transaction! |
218 | 218 |
219 LookupIdentifierQuery::StoreIdentifiers(database, resource, level, dicomSummary); | 219 LookupIdentifierQuery::StoreIdentifiers(database, resource, level, dicomSummary); |
220 | 220 |
227 break; | 227 break; |
228 | 228 |
229 case ResourceType_Study: | 229 case ResourceType_Study: |
230 // Duplicate the patient tags at the study level (new in Orthanc 0.9.5 - db v6) | 230 // Duplicate the patient tags at the study level (new in Orthanc 0.9.5 - db v6) |
231 dicomSummary.ExtractPatientInformation(tags); | 231 dicomSummary.ExtractPatientInformation(tags); |
232 SetMainDicomTagsInternal(database, resource, tags); | 232 StoreMainDicomTagsInternal(database, resource, tags); |
233 | 233 |
234 dicomSummary.ExtractStudyInformation(tags); | 234 dicomSummary.ExtractStudyInformation(tags); |
235 break; | 235 break; |
236 | 236 |
237 case ResourceType_Series: | 237 case ResourceType_Series: |
244 | 244 |
245 default: | 245 default: |
246 throw OrthancException(ErrorCode_InternalError); | 246 throw OrthancException(ErrorCode_InternalError); |
247 } | 247 } |
248 | 248 |
249 SetMainDicomTagsInternal(database, resource, tags); | 249 StoreMainDicomTagsInternal(database, resource, tags); |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 bool FindOneChildInstance(int64_t& result, | 253 bool FindOneChildInstance(int64_t& result, |
254 IDatabaseWrapper& database, | 254 IDatabaseWrapper& database, |
348 // Update the tags of this resource | 348 // Update the tags of this resource |
349 DicomMap dicomSummary; | 349 DicomMap dicomSummary; |
350 dicom.Convert(dicomSummary); | 350 dicom.Convert(dicomSummary); |
351 | 351 |
352 database.ClearMainDicomTags(resource); | 352 database.ClearMainDicomTags(resource); |
353 Toolbox::SetMainDicomTags(database, resource, level, dicomSummary); | 353 StoreMainDicomTags(database, resource, level, dicomSummary); |
354 } | 354 } |
355 catch (OrthancException&) | 355 catch (OrthancException&) |
356 { | 356 { |
357 LOG(ERROR) << "Cannot decode the DICOM file with UUID " << attachment.GetUuid() | 357 LOG(ERROR) << "Cannot decode the DICOM file with UUID " << attachment.GetUuid() |
358 << " associated with instance " << database.GetPublicId(instance); | 358 << " associated with instance " << database.GetPublicId(instance); |