Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 3009:750de70b3603
make "/tools/create-dicom" more tolerant to invalid specific character set
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 13 Dec 2018 17:19:50 +0100 |
parents | bbfd95a0c429 |
children | 4e43e67f8ecf |
comparison
equal
deleted
inserted
replaced
3008:45a4a1571b4e | 3009:750de70b3603 |
---|---|
438 } | 438 } |
439 | 439 |
440 // Select one existing child instance of the parent resource, to | 440 // Select one existing child instance of the parent resource, to |
441 // retrieve all its tags | 441 // retrieve all its tags |
442 Json::Value siblingTags; | 442 Json::Value siblingTags; |
443 std::string siblingInstanceId; | |
443 | 444 |
444 { | 445 { |
445 // Retrieve all the instances of the parent resource | 446 // Retrieve all the instances of the parent resource |
446 std::list<std::string> siblingInstances; | 447 std::list<std::string> siblingInstances; |
447 context.GetIndex().GetChildInstances(siblingInstances, parent); | 448 context.GetIndex().GetChildInstances(siblingInstances, parent); |
450 { | 451 { |
451 // Error: No instance (should never happen) | 452 // Error: No instance (should never happen) |
452 throw OrthancException(ErrorCode_InternalError); | 453 throw OrthancException(ErrorCode_InternalError); |
453 } | 454 } |
454 | 455 |
455 context.ReadDicomAsJson(siblingTags, siblingInstances.front()); | 456 siblingInstanceId = siblingInstances.front(); |
457 context.ReadDicomAsJson(siblingTags, siblingInstanceId); | |
456 } | 458 } |
457 | 459 |
458 | 460 |
459 // Choose the same encoding as the parent resource | 461 // Choose the same encoding as the parent resource |
460 { | 462 { |
461 static const char* SPECIFIC_CHARACTER_SET = "0008,0005"; | 463 static const char* SPECIFIC_CHARACTER_SET = "0008,0005"; |
462 | 464 |
463 if (siblingTags.isMember(SPECIFIC_CHARACTER_SET)) | 465 if (siblingTags.isMember(SPECIFIC_CHARACTER_SET)) |
464 { | 466 { |
465 Encoding encoding; | 467 Encoding encoding; |
468 | |
466 if (!siblingTags[SPECIFIC_CHARACTER_SET].isMember("Value") || | 469 if (!siblingTags[SPECIFIC_CHARACTER_SET].isMember("Value") || |
467 siblingTags[SPECIFIC_CHARACTER_SET]["Value"].type() != Json::stringValue || | 470 siblingTags[SPECIFIC_CHARACTER_SET]["Value"].type() != Json::stringValue || |
468 !GetDicomEncoding(encoding, siblingTags[SPECIFIC_CHARACTER_SET]["Value"].asCString())) | 471 !GetDicomEncoding(encoding, siblingTags[SPECIFIC_CHARACTER_SET]["Value"].asCString())) |
469 { | 472 { |
470 throw OrthancException(ErrorCode_CreateDicomParentEncoding); | 473 LOG(WARNING) << "Instance with an incorrect Specific Character Set, " |
474 << "using the default Orthanc encoding: " << siblingInstanceId; | |
475 encoding = GetDefaultDicomEncoding(); | |
471 } | 476 } |
472 | 477 |
473 dicom.SetEncoding(encoding); | 478 dicom.SetEncoding(encoding); |
474 } | 479 } |
475 } | 480 } |