comparison OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 1982:b5d4f9c156ad

Modification of instances can now replace PixelData
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 Apr 2016 10:28:55 +0200
parents 72a2fd7fed8b
children 2b1520efa282
comparison
equal deleted inserted replaced
1981:4b545a8b1f95 1982:b5d4f9c156ad
478 { 478 {
479 dicom.EmbedContent(value); 479 dicom.EmbedContent(value);
480 } 480 }
481 else 481 else
482 { 482 {
483 dicom.Replace(tag, value); 483 // This is V1, don't try and decode data URI scheme
484 dicom.ReplacePlainString(tag, value);
484 } 485 }
485 } 486 }
486 } 487 }
487 488
488 489
524 { 525 {
525 throw OrthancException(ErrorCode_CreateDicomUseContent); 526 throw OrthancException(ErrorCode_CreateDicomUseContent);
526 } 527 }
527 else 528 else
528 { 529 {
529 dicom.Replace(tag, tags[name], decodeBinaryTags); 530 dicom.Replace(tag, tags[name], decodeBinaryTags, DicomReplaceMode_InsertIfAbsent);
530 } 531 }
531 } 532 }
532 } 533 }
533 } 534 }
534 535
540 { 541 {
541 assert(content.isArray()); 542 assert(content.isArray());
542 assert(content.size() > 0); 543 assert(content.size() > 0);
543 ServerContext& context = OrthancRestApi::GetContext(call); 544 ServerContext& context = OrthancRestApi::GetContext(call);
544 545
545 base.Replace(DICOM_TAG_IMAGES_IN_ACQUISITION, boost::lexical_cast<std::string>(content.size())); 546 base.ReplacePlainString(DICOM_TAG_IMAGES_IN_ACQUISITION, boost::lexical_cast<std::string>(content.size()));
546 base.Replace(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, "1"); 547 base.ReplacePlainString(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, "1");
547 548
548 std::string someInstance; 549 std::string someInstance;
549 550
550 try 551 try
551 { 552 {
578 { 579 {
579 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); 580 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme);
580 } 581 }
581 582
582 dicom->EmbedContent(payload->asString()); 583 dicom->EmbedContent(payload->asString());
583 dicom->Replace(DICOM_TAG_INSTANCE_NUMBER, boost::lexical_cast<std::string>(i + 1)); 584 dicom->ReplacePlainString(DICOM_TAG_INSTANCE_NUMBER, boost::lexical_cast<std::string>(i + 1));
584 dicom->Replace(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1)); 585 dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1));
585 586
586 StoreCreatedInstance(someInstance, call, *dicom); 587 StoreCreatedInstance(someInstance, call, *dicom);
587 } 588 }
588 } 589 }
589 catch (OrthancException&) 590 catch (OrthancException&)
728 if (siblingTags.isMember(t)) 729 if (siblingTags.isMember(t))
729 { 730 {
730 const Json::Value& tag = siblingTags[t]; 731 const Json::Value& tag = siblingTags[t];
731 if (tag["Type"] == "Null") 732 if (tag["Type"] == "Null")
732 { 733 {
733 dicom.Replace(*it, ""); 734 dicom.ReplacePlainString(*it, "");
734 } 735 }
735 else if (tag["Type"] == "String") 736 else if (tag["Type"] == "String")
736 { 737 {
737 std::string value = tag["Value"].asString(); 738 std::string value = tag["Value"].asString();
738 dicom.Replace(*it, Toolbox::ConvertFromUtf8(value, dicom.GetEncoding())); 739 dicom.ReplacePlainString(*it, Toolbox::ConvertFromUtf8(value, dicom.GetEncoding()));
739 } 740 }
740 } 741 }
741 } 742 }
742 } 743 }
743 744
756 757
757 758
758 // Inject time-related information 759 // Inject time-related information
759 std::string date, time; 760 std::string date, time;
760 Toolbox::GetNowDicom(date, time); 761 Toolbox::GetNowDicom(date, time);
761 dicom.Replace(DICOM_TAG_ACQUISITION_DATE, date); 762 dicom.ReplacePlainString(DICOM_TAG_ACQUISITION_DATE, date);
762 dicom.Replace(DICOM_TAG_ACQUISITION_TIME, time); 763 dicom.ReplacePlainString(DICOM_TAG_ACQUISITION_TIME, time);
763 dicom.Replace(DICOM_TAG_CONTENT_DATE, date); 764 dicom.ReplacePlainString(DICOM_TAG_CONTENT_DATE, date);
764 dicom.Replace(DICOM_TAG_CONTENT_TIME, time); 765 dicom.ReplacePlainString(DICOM_TAG_CONTENT_TIME, time);
765 dicom.Replace(DICOM_TAG_INSTANCE_CREATION_DATE, date); 766 dicom.ReplacePlainString(DICOM_TAG_INSTANCE_CREATION_DATE, date);
766 dicom.Replace(DICOM_TAG_INSTANCE_CREATION_TIME, time); 767 dicom.ReplacePlainString(DICOM_TAG_INSTANCE_CREATION_TIME, time);
767 768
768 if (parentType == ResourceType_Patient || 769 if (parentType == ResourceType_Patient ||
769 parentType == ResourceType_Study || 770 parentType == ResourceType_Study ||
770 parentType == ResourceType_Instance /* no parent */) 771 parentType == ResourceType_Instance /* no parent */)
771 { 772 {
772 dicom.Replace(DICOM_TAG_SERIES_DATE, date); 773 dicom.ReplacePlainString(DICOM_TAG_SERIES_DATE, date);
773 dicom.Replace(DICOM_TAG_SERIES_TIME, time); 774 dicom.ReplacePlainString(DICOM_TAG_SERIES_TIME, time);
774 } 775 }
775 776
776 if (parentType == ResourceType_Patient || 777 if (parentType == ResourceType_Patient ||
777 parentType == ResourceType_Instance /* no parent */) 778 parentType == ResourceType_Instance /* no parent */)
778 { 779 {
779 dicom.Replace(DICOM_TAG_STUDY_DATE, date); 780 dicom.ReplacePlainString(DICOM_TAG_STUDY_DATE, date);
780 dicom.Replace(DICOM_TAG_STUDY_TIME, time); 781 dicom.ReplacePlainString(DICOM_TAG_STUDY_TIME, time);
781 } 782 }
782 783
783 784
784 InjectTags(dicom, request["Tags"], decodeBinaryTags); 785 InjectTags(dicom, request["Tags"], decodeBinaryTags);
785 786