Mercurial > hg > orthanc
diff OrthancServer/Sources/OrthancInitialization.cpp @ 4934:94a7b681b340 more-tags
added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 10 Mar 2022 09:03:24 +0100 |
parents | 6eff25f70121 |
children | f377d5643538 |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancInitialization.cpp Wed Mar 09 12:16:45 2022 +0100 +++ b/OrthancServer/Sources/OrthancInitialization.cpp Thu Mar 10 09:03:24 2022 +0100 @@ -200,6 +200,64 @@ } } + static void LoadMainDicomTags(const Json::Value& configuration) + { + static const char* const EXTRA_MAIN_DICOM_TAGS = "ExtraMainDicomTags"; + + if (configuration.type() != Json::objectValue || + !configuration.isMember(EXTRA_MAIN_DICOM_TAGS) || + configuration[EXTRA_MAIN_DICOM_TAGS].type() != Json::objectValue) + { + return; + } + + Json::Value::Members levels(configuration[EXTRA_MAIN_DICOM_TAGS].getMemberNames()); + + for (Json::Value::ArrayIndex i = 0; i < levels.size(); i++) + { + ResourceType level; + if (levels[i] == "Patient") + { + level = ResourceType_Patient; + } + else if (levels[i] == "Study") + { + level = ResourceType_Study; + } + else if (levels[i] == "Series") + { + level = ResourceType_Series; + } + else if (levels[i] == "Instance") + { + level = ResourceType_Instance; + } + else + { + throw OrthancException(ErrorCode_BadFileFormat, "Unknown entry '" + levels[i] + "' in ExtraMainDicomTags."); + } + + const Json::Value& content = configuration[EXTRA_MAIN_DICOM_TAGS][levels[i]]; + + if (content.type() != Json::arrayValue) + { + throw OrthancException(ErrorCode_BadFileFormat, "The definition of the '" + levels[i] + "' ExtraMainDicomTags entry is invalid (not an array)."); + } + + if (content.size() > 0) + { + LOG(INFO) << "Configured Extra Main Dicom Tags for " << levels[i] << ":"; + + for (Json::Value::ArrayIndex t = 0; t < content.size(); t++) + { + const std::string& tagName = content[t].asString(); + DicomTag tag(FromDcmtkBridge::ParseTag(tagName)); + DicomMap::AddMainDicomTag(tag, tagName, level); + LOG(INFO) << " - " << tagName; + } + } + } + } static void ConfigurePkcs11(const Json::Value& config) { @@ -299,6 +357,8 @@ LoadExternalDictionaries(lock.GetJson()); // New in Orthanc 1.9.4 LoadCustomDictionary(lock.GetJson()); + LoadMainDicomTags(lock.GetJson()); // New in Orthanc 1.11.0 + lock.GetConfiguration().RegisterFont(ServerResources::FONT_UBUNTU_MONO_BOLD_16); #if HAVE_MALLOPT == 1