comparison OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 1558:124de28b32ed

fix encodings of newly created dicom files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Aug 2015 17:40:07 +0200
parents ad1e127b4ed5
children 2084b7c20478
comparison
equal deleted inserted replaced
1557:ad1e127b4ed5 1558:124de28b32ed
475 request["Tags"].type() != Json::objectValue) 475 request["Tags"].type() != Json::objectValue)
476 { 476 {
477 return false; 477 return false;
478 } 478 }
479 479
480 std::string tmp; 480 Encoding encoding;
481
481 if (request["Tags"].isMember("SpecificCharacterSet")) 482 if (request["Tags"].isMember("SpecificCharacterSet"))
482 { 483 {
483 tmp = request["Tags"]["SpecificCharacterSet"].asString(); 484 const char* tmp = request["Tags"]["SpecificCharacterSet"].asCString();
485 if (!GetDicomEncoding(encoding, tmp))
486 {
487 LOG(ERROR) << "Unknown specific character set: " << tmp;
488 return false;
489 }
484 } 490 }
485 else 491 else
486 { 492 {
487 tmp = Configuration::GetGlobalStringParameter("DefaultEncoding", "Latin1"); 493 std::string tmp = Configuration::GetGlobalStringParameter("DefaultEncoding", "Latin1");
488 } 494 encoding = StringToEncoding(tmp.c_str());
489 495 }
490 Encoding encoding = StringToEncoding(tmp.c_str()); 496
491 dicom.SetEncoding(encoding); 497 dicom.SetEncoding(encoding);
492 498
493 ResourceType parentType = ResourceType_Instance; 499 ResourceType parentType = ResourceType_Instance;
494 500
495 if (request.isMember("Parent")) 501 if (request.isMember("Parent"))
609 } 615 }
610 616
611 std::string value = request["Tags"][name].asString(); 617 std::string value = request["Tags"][name].asString();
612 618
613 DicomTag tag = FromDcmtkBridge::ParseTag(name); 619 DicomTag tag = FromDcmtkBridge::ParseTag(name);
614 if (dicom.HasTag(tag)) 620 if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET)
615 { 621 {
616 LOG(ERROR) << "Trying to override a value inherited from a parent module"; 622 if (dicom.HasTag(tag))
617 return false; 623 {
618 } 624 LOG(ERROR) << "Trying to override a value inherited from a parent module";
619 625 return false;
620 if (tag == DICOM_TAG_PIXEL_DATA) 626 }
621 { 627
622 LOG(ERROR) << "Use \"Content\" to inject an image into a new DICOM instance"; 628 if (tag == DICOM_TAG_PIXEL_DATA)
623 return false; 629 {
624 } 630 LOG(ERROR) << "Use \"Content\" to inject an image into a new DICOM instance";
625 else 631 return false;
626 { 632 }
627 dicom.Replace(tag, Toolbox::ConvertFromUtf8(value, encoding)); 633 else
634 {
635 dicom.Replace(tag, Toolbox::ConvertFromUtf8(value, encoding));
636 }
628 } 637 }
629 } 638 }
630 639
631 640
632 // Inject the content (either an image, or a PDF file) 641 // Inject the content (either an image, or a PDF file)