Mercurial > hg > orthanc
diff OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 4697:569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Jun 2021 16:08:35 +0200 |
parents | dd6274412ff4 |
children | b51c08bd5c38 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Thu Jun 17 15:47:21 2021 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Fri Jun 18 16:08:35 2021 +0200 @@ -1329,7 +1329,7 @@ void FromDcmtkBridge::ToJson(Json::Value& result, const DicomMap& values, - bool simplify) + DicomToJsonFormat format) { if (result.type() != Json::objectValue) { @@ -1341,40 +1341,69 @@ for (DicomMap::Content::const_iterator it = values.content_.begin(); it != values.content_.end(); ++it) { - // TODO Inject PrivateCreator if some is available in the DicomMap? - const std::string tagName = GetTagName(it->first, ""); - - if (simplify) - { - if (it->second->IsNull()) - { - result[tagName] = Json::nullValue; - } - else - { - // TODO IsBinary - result[tagName] = it->second->GetContent(); - } - } - else + switch (format) { - Json::Value value = Json::objectValue; - - value["Name"] = tagName; - - if (it->second->IsNull()) + case DicomToJsonFormat_Human: { - value["Type"] = "Null"; - value["Value"] = Json::nullValue; + // TODO Inject PrivateCreator if some is available in the DicomMap? + const std::string tagName = GetTagName(it->first, ""); + + if (it->second->IsNull()) + { + result[tagName] = Json::nullValue; + } + else + { + // TODO IsBinary + result[tagName] = it->second->GetContent(); + } + break; } - else + + case DicomToJsonFormat_Full: { - // TODO IsBinary - value["Type"] = "String"; - value["Value"] = it->second->GetContent(); + // TODO Inject PrivateCreator if some is available in the DicomMap? + const std::string tagName = GetTagName(it->first, ""); + + Json::Value value = Json::objectValue; + + value["Name"] = tagName; + + if (it->second->IsNull()) + { + value["Type"] = "Null"; + value["Value"] = Json::nullValue; + } + else + { + // TODO IsBinary + value["Type"] = "String"; + value["Value"] = it->second->GetContent(); + } + + result[it->first.Format()] = value; + break; } - result[it->first.Format()] = value; + case DicomToJsonFormat_Short: + { + const std::string hex = it->first.Format(); + + if (it->second->IsNull()) + { + result[hex] = Json::nullValue; + } + else + { + // TODO IsBinary + result[hex] = it->second->GetContent(); + } + + break; + } + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); } } }