Mercurial > hg > orthanc
comparison OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp @ 4737:979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Jul 2021 08:12:26 +0200 |
parents | bf852fd773b7 |
children | c125632f9468 |
comparison
equal
deleted
inserted
replaced
4736:bf852fd773b7 | 4737:979ae3ea3381 |
---|---|
2712 ASSERT_TRUE(Toolbox::IsUuid(vv1[PATIENT_NAME].asString())); | 2712 ASSERT_TRUE(Toolbox::IsUuid(vv1[PATIENT_NAME].asString())); |
2713 ASSERT_EQ("1.2.840.10008.5.1.4.1.1.4", vv1[REF_IM_SEQ][0][REF_SOP_CLASS].asString()); | 2713 ASSERT_EQ("1.2.840.10008.5.1.4.1.1.4", vv1[REF_IM_SEQ][0][REF_SOP_CLASS].asString()); |
2714 ASSERT_NE("1.2.840.113619.2.176.2025.1499492.7040.1171286241.719", vv1[REF_IM_SEQ][0][REF_SOP_INSTANCE].asString()); | 2714 ASSERT_NE("1.2.840.113619.2.176.2025.1499492.7040.1171286241.719", vv1[REF_IM_SEQ][0][REF_SOP_INSTANCE].asString()); |
2715 ASSERT_NE("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", vv1[REF_IM_SEQ][1][REF_SOP_INSTANCE].asString()); | 2715 ASSERT_NE("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", vv1[REF_IM_SEQ][1][REF_SOP_INSTANCE].asString()); |
2716 ASSERT_NE("1.2.840.113704.1.111.7016.1342451220.40", vv1[REL_SERIES_SEQ][0][STUDY_INSTANCE_UID].asString()); | 2716 ASSERT_NE("1.2.840.113704.1.111.7016.1342451220.40", vv1[REL_SERIES_SEQ][0][STUDY_INSTANCE_UID].asString()); |
2717 ASSERT_EQ("WORLD", vv1[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0][SERIES_DESCRIPTION].asString()); | 2717 |
2718 // Contrarily to Orthanc 1.9.4, the "SERIES_DESCRIPTION" is also removed from nested sequences | |
2719 ASSERT_EQ(1u, vv1[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0].size()); | |
2720 ASSERT_EQ("122403", vv1[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0]["0008,0100"].asString()); | |
2718 } | 2721 } |
2719 | 2722 |
2720 { | 2723 { |
2721 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); | 2724 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
2722 | 2725 |
2772 { | 2775 { |
2773 throw OrthancException(ErrorCode_InternalError); | 2776 throw OrthancException(ErrorCode_InternalError); |
2774 } | 2777 } |
2775 } | 2778 } |
2776 | 2779 |
2777 virtual Action VisitEmptySequence(const std::vector<DicomTag>& parentTags, | 2780 virtual Action VisitSequence(const std::vector<DicomTag>& parentTags, |
2778 const std::vector<size_t>& parentIndexes, | 2781 const std::vector<size_t>& parentIndexes, |
2779 const DicomTag& tag) ORTHANC_OVERRIDE | 2782 const DicomTag& tag, |
2783 size_t countItems) ORTHANC_OVERRIDE | |
2780 { | 2784 { |
2781 seen_ |= (1 << 1); | 2785 seen_ |= (1 << 1); |
2782 | 2786 |
2783 if (parentTags.size() == 1u && | 2787 if (parentTags.size() == 0u && |
2784 parentIndexes.size() == 1u && | 2788 parentIndexes.size() == 0u && |
2785 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && | 2789 tag == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && |
2786 parentIndexes[0] == 0u && | 2790 countItems == 1) |
2787 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_ReferencedPatientSequence) | 2791 { |
2792 return Action_None; | |
2793 } | |
2794 else if (parentTags.size() == 1u && | |
2795 parentIndexes.size() == 1u && | |
2796 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && | |
2797 parentIndexes[0] == 0u && | |
2798 countItems == 0 && | |
2799 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_ReferencedPatientSequence) | |
2800 { | |
2801 return Action_Remove; | |
2802 } | |
2803 else if (parentTags.size() == 1u && | |
2804 parentIndexes.size() == 1u && | |
2805 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && | |
2806 parentIndexes[0] == 0u && | |
2807 countItems == 1 && | |
2808 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_ReferencedStudySequence) | |
2788 { | 2809 { |
2789 return Action_Remove; | 2810 return Action_Remove; |
2790 } | 2811 } |
2791 else | 2812 else |
2792 { | 2813 { |
2912 Json::Value v = Json::objectValue; | 2933 Json::Value v = Json::objectValue; |
2913 v["PatientName"] = "Hello"; | 2934 v["PatientName"] = "Hello"; |
2914 v["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; | 2935 v["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; |
2915 v["ReferencedImageSequence"][0]["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; | 2936 v["ReferencedImageSequence"][0]["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; |
2916 v["ReferencedImageSequence"][0]["ReferencedSOPInstanceUID"] = "1.2.840.113619.2.176.2025.1499492.7040.1171286241.719"; | 2937 v["ReferencedImageSequence"][0]["ReferencedSOPInstanceUID"] = "1.2.840.113619.2.176.2025.1499492.7040.1171286241.719"; |
2917 v["ReferencedImageSequence"][0]["ReferencedPatientSequence"] = Json::arrayValue; // Empty sequence | 2938 v["ReferencedImageSequence"][0]["ReferencedPatientSequence"] = Json::arrayValue; // Empty nested sequence |
2939 v["ReferencedImageSequence"][0]["ReferencedStudySequence"][0]["PatientID"] = "Hello"; // Non-empty nested sequence | |
2918 v["ReferencedImageSequence"][0]["0011,1311"] = "abcd"; // Binary | 2940 v["ReferencedImageSequence"][0]["0011,1311"] = "abcd"; // Binary |
2919 | 2941 |
2920 dicom.reset(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "PrivateCreator")); | 2942 dicom.reset(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "PrivateCreator")); |
2921 | 2943 |
2922 { | 2944 { |