Mercurial > hg > orthanc
changeset 5657:dedbf019a707
Improved parsing of multiple numerical values in DICOM tags
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 06 Jun 2024 17:55:13 +0200 |
parents | 65a509cac161 |
children | 4b7bc21db336 |
files | NEWS OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp |
diffstat | 3 files changed, 61 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed Jun 05 20:37:03 2024 +0200 +++ b/NEWS Thu Jun 06 17:55:13 2024 +0200 @@ -1,6 +1,12 @@ Pending changes in the mainline =============================== +REST API +----------- + +* Improved parsing of multiple numerical values in DICOM tags. + https://discourse.orthanc-server.org/t/qido-includefield-with-sequences/4746/6 + Version 1.12.4 (2024-06-05) ===========================
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Wed Jun 05 20:37:03 2024 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Thu Jun 06 17:55:13 2024 +0200 @@ -1978,13 +1978,27 @@ case EVR_SL: // signed long { - ok = element.putSint32(boost::lexical_cast<Sint32>(*decoded)).good(); + if (decoded->find('\\') != std::string::npos) + { + ok = element.putString(decoded->c_str()).good(); + } + else + { + ok = element.putSint32(boost::lexical_cast<Sint32>(*decoded)).good(); + } break; } case EVR_SS: // signed short { - ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good(); + if (decoded->find('\\') != std::string::npos) + { + ok = element.putString(decoded->c_str()).good(); + } + else + { + ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good(); + } break; } @@ -2023,14 +2037,28 @@ case EVR_US: // unsigned short { - ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good(); + if (decoded->find('\\') != std::string::npos) + { + ok = element.putString(decoded->c_str()).good(); + } + else + { + ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good(); + } break; } case EVR_FL: // float single-precision case EVR_OF: // other float (requires byte swapping) { - ok = element.putFloat32(boost::lexical_cast<float>(*decoded)).good(); + if (decoded->find('\\') != std::string::npos) + { + ok = element.putString(decoded->c_str()).good(); + } + else + { + ok = element.putFloat32(boost::lexical_cast<float>(*decoded)).good(); + } break; } @@ -2039,7 +2067,14 @@ case EVR_OD: // other double (requires byte-swapping) #endif { - ok = element.putFloat64(boost::lexical_cast<double>(*decoded)).good(); + if (decoded->find('\\') != std::string::npos) + { + ok = element.putString(decoded->c_str()).good(); + } + else + { + ok = element.putFloat64(boost::lexical_cast<double>(*decoded)).good(); + } break; }
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Wed Jun 05 20:37:03 2024 +0200 +++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Thu Jun 06 17:55:13 2024 +0200 @@ -3092,6 +3092,21 @@ } +TEST(ParsedDicomFile, MultipleFloatValue) +{ + // from https://discourse.orthanc-server.org/t/qido-includefield-with-sequences/4746/6 + Json::Value v = Json::objectValue; + v["4010,1001"][0]["4010,1004"] = "30\\20\\10"; + std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); + ASSERT_TRUE(dicom->HasTag(Orthanc::DicomTag(0x4010, 0x1001))); + + DicomMap m; + ASSERT_TRUE(dicom->LookupSequenceItem(m, DicomPath(DicomTag(0x4010, 0x1001)), 0)); + ASSERT_EQ(1u, m.GetSize()); + std::string value = m.GetStringValue(DicomTag(0x4010, 0x1004), "", false); + ASSERT_EQ("30\\20\\10", value); +} + TEST(ParsedDicomFile, ImageInformation) {