Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
4696:dd6274412ff4 | 4697:569d9ef165b1 |
---|---|
1327 } | 1327 } |
1328 | 1328 |
1329 | 1329 |
1330 void FromDcmtkBridge::ToJson(Json::Value& result, | 1330 void FromDcmtkBridge::ToJson(Json::Value& result, |
1331 const DicomMap& values, | 1331 const DicomMap& values, |
1332 bool simplify) | 1332 DicomToJsonFormat format) |
1333 { | 1333 { |
1334 if (result.type() != Json::objectValue) | 1334 if (result.type() != Json::objectValue) |
1335 { | 1335 { |
1336 throw OrthancException(ErrorCode_BadParameterType); | 1336 throw OrthancException(ErrorCode_BadParameterType); |
1337 } | 1337 } |
1339 result.clear(); | 1339 result.clear(); |
1340 | 1340 |
1341 for (DicomMap::Content::const_iterator | 1341 for (DicomMap::Content::const_iterator |
1342 it = values.content_.begin(); it != values.content_.end(); ++it) | 1342 it = values.content_.begin(); it != values.content_.end(); ++it) |
1343 { | 1343 { |
1344 // TODO Inject PrivateCreator if some is available in the DicomMap? | 1344 switch (format) |
1345 const std::string tagName = GetTagName(it->first, ""); | 1345 { |
1346 | 1346 case DicomToJsonFormat_Human: |
1347 if (simplify) | 1347 { |
1348 { | 1348 // TODO Inject PrivateCreator if some is available in the DicomMap? |
1349 if (it->second->IsNull()) | 1349 const std::string tagName = GetTagName(it->first, ""); |
1350 { | 1350 |
1351 result[tagName] = Json::nullValue; | 1351 if (it->second->IsNull()) |
1352 } | 1352 { |
1353 else | 1353 result[tagName] = Json::nullValue; |
1354 { | 1354 } |
1355 // TODO IsBinary | 1355 else |
1356 result[tagName] = it->second->GetContent(); | 1356 { |
1357 } | 1357 // TODO IsBinary |
1358 } | 1358 result[tagName] = it->second->GetContent(); |
1359 else | 1359 } |
1360 { | 1360 break; |
1361 Json::Value value = Json::objectValue; | 1361 } |
1362 | 1362 |
1363 value["Name"] = tagName; | 1363 case DicomToJsonFormat_Full: |
1364 | 1364 { |
1365 if (it->second->IsNull()) | 1365 // TODO Inject PrivateCreator if some is available in the DicomMap? |
1366 { | 1366 const std::string tagName = GetTagName(it->first, ""); |
1367 value["Type"] = "Null"; | 1367 |
1368 value["Value"] = Json::nullValue; | 1368 Json::Value value = Json::objectValue; |
1369 } | 1369 |
1370 else | 1370 value["Name"] = tagName; |
1371 { | 1371 |
1372 // TODO IsBinary | 1372 if (it->second->IsNull()) |
1373 value["Type"] = "String"; | 1373 { |
1374 value["Value"] = it->second->GetContent(); | 1374 value["Type"] = "Null"; |
1375 } | 1375 value["Value"] = Json::nullValue; |
1376 | 1376 } |
1377 result[it->first.Format()] = value; | 1377 else |
1378 { | |
1379 // TODO IsBinary | |
1380 value["Type"] = "String"; | |
1381 value["Value"] = it->second->GetContent(); | |
1382 } | |
1383 | |
1384 result[it->first.Format()] = value; | |
1385 break; | |
1386 } | |
1387 | |
1388 case DicomToJsonFormat_Short: | |
1389 { | |
1390 const std::string hex = it->first.Format(); | |
1391 | |
1392 if (it->second->IsNull()) | |
1393 { | |
1394 result[hex] = Json::nullValue; | |
1395 } | |
1396 else | |
1397 { | |
1398 // TODO IsBinary | |
1399 result[hex] = it->second->GetContent(); | |
1400 } | |
1401 | |
1402 break; | |
1403 } | |
1404 | |
1405 default: | |
1406 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1378 } | 1407 } |
1379 } | 1408 } |
1380 } | 1409 } |
1381 | 1410 |
1382 | 1411 |