# HG changeset patch # User Alain Mazy # Date 1726570131 -7200 # Node ID 42ef98bb3c13147646172ac6fc1936b24e129b44 # Parent 09e337d45d226b6514d177e327a774fe1991938b Do not read from disk when not required diff -r 09e337d45d22 -r 42ef98bb3c13 OrthancServer/Resources/Configuration.json --- a/OrthancServer/Resources/Configuration.json Tue Sep 17 12:47:42 2024 +0200 +++ b/OrthancServer/Resources/Configuration.json Tue Sep 17 12:48:51 2024 +0200 @@ -985,12 +985,21 @@ // saved with another "ExtraMainDicomTags" configuration which means that // your response might be incomplete/inconsistent. // You should call patients|studies|series|instances/../reconstruct to rebuild - // the DB. You may also check for the "Housekeeper" plugin + // the DB. You may also check for the "Housekeeper" plugin. "W002_InconsistentDicomTagsInDb": true, // Display a warning message when Orthanc and its plugins are unable // to decode a frame (new in Orthanc 1.12.5). - "W003_DecoderFailure": true + "W003_DecoderFailure": true, + + // Display a warning when the MainDicomTagsSignature metadata has not been + // found which means that the resource has been saved with a version prior + // to 1.11.0. + // You should call patients|studies|series|instances/../reconstruct to rebuild + // the DB. You may also check for the "Housekeeper" plugin. + // (new in Orthanc 1.12.5) + "W004_NoMainDicomTagsSignature": true + }, // Configure Orthanc in read only mode. diff -r 09e337d45d22 -r 42ef98bb3c13 OrthancServer/Sources/OrthancConfiguration.cpp --- a/OrthancServer/Sources/OrthancConfiguration.cpp Tue Sep 17 12:47:42 2024 +0200 +++ b/OrthancServer/Sources/OrthancConfiguration.cpp Tue Sep 17 12:48:51 2024 +0200 @@ -1161,6 +1161,10 @@ { warning = Warnings_003_DecoderFailure; } + else if (name == "W004_NoMainDicomTagsSignature") + { + warning = Warnings_004_NoMainDicomTagsSignature; + } else { throw OrthancException(ErrorCode_BadFileFormat, name + " is not recognized as a valid warning name"); diff -r 09e337d45d22 -r 42ef98bb3c13 OrthancServer/Sources/ResourceFinder.cpp --- a/OrthancServer/Sources/ResourceFinder.cpp Tue Sep 17 12:47:42 2024 +0200 +++ b/OrthancServer/Sources/ResourceFinder.cpp Tue Sep 17 12:48:51 2024 +0200 @@ -807,6 +807,19 @@ { DicomMap m; resource.GetMainDicomTags(m, level); + + // check which tags have been saved in DB + std::set savedMainDicomTags; + std::string signature = DicomMap::GetDefaultMainDicomTagsSignature(ResourceType_Study); // default signature in case it's not in the metadata (= the signature for 1.11.0) + if (resource.LookupMetadata(signature, level, MetadataType_MainDicomTagsSignature)) + { + if (level == ResourceType_Study) // when we retrieve the study tags, we actually also get the patient tags that are also saved at study level but not included in the signature + { + signature += ";" + DicomMap::GetDefaultMainDicomTagsSignature(ResourceType_Patient); // append the default signature (from before 1.11.0) + } + + FromDcmtkBridge::ParseListOfTags(savedMainDicomTags, signature); + } for (std::set::const_iterator it = tags.begin(); it != tags.end(); ++it) { @@ -815,9 +828,9 @@ { requestedTags.SetValue(*it, value, false /* not binary */); } - else + else if (savedMainDicomTags.find(*it) == savedMainDicomTags.end()) { - // This is the case where the Housekeeper should be run + // This is the case where the Housekeeper should be run because the tag has not been saved in DB missingTags.insert(*it); } } @@ -930,10 +943,12 @@ ServerContext& context) const { bool isWarning002Enabled = false; + bool isWarning004Enabled = false; { OrthancConfiguration::ReaderLock lock; isWarning002Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb); + isWarning004Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature); } FindResponse response; @@ -983,7 +998,7 @@ { InjectComputedTags(requestedTags, resource); - std::set missingTags = requestedTagsFromFileStorage_; + std::set missingTags = requestedTagsFromFileStorage_; // this is actually the full list of requestedTags InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Patient, requestedPatientTags_); InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Study, requestedStudyTags_); InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Series, requestedSeriesTags_); @@ -1013,6 +1028,15 @@ << "/" << resource.GetIdentifier() << "/reconstruct to update the list of tags saved in DB or run the Housekeeper plugin. Some MainDicomTags might be missing from this answer."; } + else if (isWarning004Enabled && + !resource.LookupMetadata(mainDicomTagsSignature, resource.GetLevel(), MetadataType_MainDicomTagsSignature)) + { + LOG(WARNING) << "W004: " << Orthanc::GetResourceTypeText(resource.GetLevel(), false , false) + << " has been stored a while ago and does not have a MainDicomTagsSignature, you should POST to /" + << Orthanc::GetResourceTypeText(resource.GetLevel(), true, false) + << "/" << resource.GetIdentifier() + << "/reconstruct to update the list of tags saved in DB or run the Housekeeper plugin. Some MainDicomTags might be missing from this answer."; + } } diff -r 09e337d45d22 -r 42ef98bb3c13 OrthancServer/Sources/ServerEnumerations.h --- a/OrthancServer/Sources/ServerEnumerations.h Tue Sep 17 12:47:42 2024 +0200 +++ b/OrthancServer/Sources/ServerEnumerations.h Tue Sep 17 12:48:51 2024 +0200 @@ -218,6 +218,7 @@ Warnings_001_TagsBeingReadFromStorage, Warnings_002_InconsistentDicomTagsInDb, Warnings_003_DecoderFailure, // new in Orthanc 1.12.5 + Warnings_004_NoMainDicomTagsSignature // new in Orthanc 1.12.5 };