Mercurial > hg > orthanc
changeset 4941:96a3e81eba90 more-tags
performance warning
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 16 Mar 2022 09:50:33 +0100 |
parents | 304514ce84ee |
children | f377d5643538 |
files | OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h OrthancFramework/Sources/Toolbox.h OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp OrthancServer/Sources/OrthancConfiguration.cpp OrthancServer/Sources/OrthancConfiguration.h OrthancServer/Sources/ServerContext.cpp |
diffstat | 7 files changed, 70 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Tue Mar 15 15:57:21 2022 +0100 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Wed Mar 16 09:50:33 2022 +0100 @@ -1311,6 +1311,17 @@ return fields.HasTag(ParseTag(tagName)); } + void FromDcmtkBridge::FormatListOfTags(std::string& output, const std::set<DicomTag>& tags) + { + std::set<std::string> values; + for (std::set<DicomTag>::const_iterator it = tags.begin(); + it != tags.end(); it++) + { + values.insert(it->Format()); + } + + Toolbox::JoinStrings(output, values, ";"); + } // parses a list like "0010,0010;PatientBirthDate;0020,0020" void FromDcmtkBridge::ParseListOfTags(std::set<DicomTag>& result, const std::string& source)
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h Tue Mar 15 15:57:21 2022 +0100 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h Wed Mar 16 09:50:33 2022 +0100 @@ -180,6 +180,8 @@ static void ParseListOfTags(std::set<DicomTag>& result, const Json::Value& source); + static void FormatListOfTags(std::string& output, const std::set<DicomTag>& tags); + static bool HasTag(const DicomMap& fields, const std::string& tagName);
--- a/OrthancFramework/Sources/Toolbox.h Tue Mar 15 15:57:21 2022 +0100 +++ b/OrthancFramework/Sources/Toolbox.h Wed Mar 16 09:50:33 2022 +0100 @@ -234,6 +234,14 @@ } } + template <typename T> static void RemoveSets(std::set<T>& target, const std::set<T>& toRemove) + { + for (typename std::set<T>::const_iterator it = toRemove.begin(); + it != toRemove.end(); it++) + { + target.erase(*it); + } + } #if ORTHANC_ENABLE_PUGIXML == 1 static void JsonToXml(std::string& target,
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Tue Mar 15 15:57:21 2022 +0100 +++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Wed Mar 16 09:50:33 2022 +0100 @@ -369,6 +369,11 @@ ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_BIRTH_DATE) != result.end()); ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ORIENTATION) != result.end()); ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ID) == result.end()); + + // serialize to string + std::string serialized; + FromDcmtkBridge::FormatListOfTags(serialized, result); + ASSERT_EQ("0010,0010;0010,0030;0020,0020", serialized); } {// no tag @@ -395,6 +400,21 @@ ASSERT_EQ(1, result.size()); } + {// Json + Json::Value source = Json::arrayValue; + source.append("0010,0010"); + source.append("PatientBirthDate"); + source.append("0020,0020"); + std::set<DicomTag> result; + FromDcmtkBridge::ParseListOfTags(result, source); + + ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_NAME) != result.end()); + ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_BIRTH_DATE) != result.end()); + ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ORIENTATION) != result.end()); + ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ID) == result.end()); + } + + } static const DicomTag REFERENCED_STUDY_SEQUENCE(0x0008, 0x1110);
--- a/OrthancServer/Sources/OrthancConfiguration.cpp Tue Mar 15 15:57:21 2022 +0100 +++ b/OrthancServer/Sources/OrthancConfiguration.cpp Wed Mar 16 09:50:33 2022 +0100 @@ -1059,7 +1059,13 @@ { return GetBooleanParameter("EnableLogsForInconsistentMainDicomTags", true); } - + + bool OrthancConfiguration::IsStorageAccessOnFindLogsEnabled() const + { + return GetBooleanParameter("EnableLogsForStorageAccessOnFind", true); + } + + void OrthancConfiguration::DefaultExtractDicomSummary(DicomMap& target, const ParsedDicomFile& dicom) {
--- a/OrthancServer/Sources/OrthancConfiguration.h Tue Mar 15 15:57:21 2022 +0100 +++ b/OrthancServer/Sources/OrthancConfiguration.h Wed Mar 16 09:50:33 2022 +0100 @@ -244,6 +244,8 @@ bool IsInconsistentDicomTagsLogsEnabled() const; + bool IsStorageAccessOnFindLogsEnabled() const; + static void DefaultExtractDicomSummary(DicomMap& target, const ParsedDicomFile& dicom);
--- a/OrthancServer/Sources/ServerContext.cpp Tue Mar 15 15:57:21 2022 +0100 +++ b/OrthancServer/Sources/ServerContext.cpp Wed Mar 16 09:50:33 2022 +0100 @@ -2546,6 +2546,26 @@ // possibly merge missing requested tags from dicom-as-json if (!resource.missingRequestedTags_.empty() && !DicomMap::HasOnlyComputedTags(resource.missingRequestedTags_)) { + OrthancConfiguration::ReaderLock lock; + if (lock.GetConfiguration().IsStorageAccessOnFindLogsEnabled()) + { + std::set<DicomTag> missingTags; + Toolbox::AppendSets(missingTags, resource.missingRequestedTags_); + for (std::set<DicomTag>::const_iterator it = resource.missingRequestedTags_.begin(); it != resource.missingRequestedTags_.end(); it++) + { + if (DicomMap::IsComputedTag(*it)) + { + missingTags.erase(*it); + } + } + + std::string missings; + FromDcmtkBridge::FormatListOfTags(missings, missingTags); + + LOG(WARNING) << "PERFORMANCE WARNING: Accessing Dicom tags from storage when accessing " << Orthanc::GetResourceTypeText(resource.type_, false , false) << " : " << missings; + } + + std::string instanceId_ = instanceId; DicomMap tagsFromJson; @@ -2569,7 +2589,6 @@ } } - // MORE_TAGS :TODO: log "performance" warning (add an option to disable them) Json::Value tmpDicomAsJson; ReadDicomAsJson(tmpDicomAsJson, instanceId_); tagsFromJson.FromDicomAsJson(tmpDicomAsJson);