From 6d55e3c463c912011da87fafac3cf8e76bd73a7c Mon Sep 17 00:00:00 2001 From: rhaxton Date: Fri, 4 Oct 2024 14:30:17 -0700 Subject: [PATCH 1/4] updated test case to have LongCodeValue for Languange of Content Items and Descendents --- data/test_files/sr_document.dcm | Bin 5004 -> 5032 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/data/test_files/sr_document.dcm b/data/test_files/sr_document.dcm index 37c9635b5bf8c5ece4761cb01c5e87210a71f5f4..3d85e6b06803b08e7a2d07226a899a68993b2fa2 100644 GIT binary patch delta 134 zcmeBCU!gvshw;k9-sQ$d=4N^ZdgeyP1_p)(dd5Juv7VWpIRg`eFhj710E54qn`dym zi?eTtcf7HgxdI1+*u;g(n~NBKF>@;LF);l5&+y>Mi@Ljx1b$tPHCHjA-M;spQ}f*2eC From 8a16445518cf5b39ef753320b5639ec8f8f4e0f8 Mon Sep 17 00:00:00 2001 From: rhaxton Date: Fri, 4 Oct 2024 14:34:00 -0700 Subject: [PATCH 2/4] Added fix for modified test case --- src/highdicom/sr/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/highdicom/sr/utils.py b/src/highdicom/sr/utils.py index e066f60e..2cf1e341 100644 --- a/src/highdicom/sr/utils.py +++ b/src/highdicom/sr/utils.py @@ -90,10 +90,17 @@ def search_tree( matched_content_items = [] for content_item in node.ContentSequence: name_code = content_item.ConceptNameCodeSequence[0] + if hasattr(name_code, "CodeValue"): + code_value = name_code.CodeValue + elif hasattr(name_code, "LongCodeValue"): + code_value = name_code.LongCodeValue + else: + code_value = name_code.URNCodeValue + item = ContentItem( value_type=content_item.ValueType, name=CodedConcept( - value=name_code.CodeValue, + value=code_value, scheme_designator=name_code.CodingSchemeDesignator, meaning=name_code.CodeMeaning ), From 790fb020ee94d7ee36e47137d9e6e694c3edab02 Mon Sep 17 00:00:00 2001 From: rhaxton Date: Tue, 8 Oct 2024 09:48:17 -0700 Subject: [PATCH 3/4] Revert "updated test case to have LongCodeValue for Languange of Content Items and Descendents" This reverts commit 6d55e3c463c912011da87fafac3cf8e76bd73a7c. --- data/test_files/sr_document.dcm | Bin 5032 -> 5004 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/data/test_files/sr_document.dcm b/data/test_files/sr_document.dcm index 3d85e6b06803b08e7a2d07226a899a68993b2fa2..37c9635b5bf8c5ece4761cb01c5e87210a71f5f4 100644 GIT binary patch delta 78 zcmZ3X-lIODhjGuu-sO|0F^aP=a4?8XT&TRci}4pTrwkth!@vIw4<1ZD&#x~P!~o%W e0cj2f2F73yHU>i@Ljx1b$tPHCHjA-M;spQ}f*2eC delta 134 zcmeBCU!gvshw;k9-sQ$d=4N^ZdgeyP1_p)(dd5Juv7VWpIRg`eFhj710E54qn`dym zi?eTtcf7HgxdI1+*u;g(n~NBKF>@;LF);l5&+y>M Date: Tue, 8 Oct 2024 13:05:24 -0700 Subject: [PATCH 4/4] Added tests cases for URN and Lone Code Value --- src/highdicom/sr/utils.py | 2 +- tests/test_sr.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/highdicom/sr/utils.py b/src/highdicom/sr/utils.py index 2cf1e341..c27bec4d 100644 --- a/src/highdicom/sr/utils.py +++ b/src/highdicom/sr/utils.py @@ -96,7 +96,7 @@ def search_tree( code_value = name_code.LongCodeValue else: code_value = name_code.URNCodeValue - + item = ContentItem( value_type=content_item.ValueType, name=CodedConcept( diff --git a/tests/test_sr.py b/tests/test_sr.py index e774d4a7..dafd3aed 100644 --- a/tests/test_sr.py +++ b/tests/test_sr.py @@ -4476,6 +4476,38 @@ def test_find_content_items(self): items = find_content_items(self._sr_document) assert len(items) == 8 + def test_find_content_items_with_URN_code_value(self): + file_path = Path(__file__) + data_dir = file_path.parent.parent.joinpath('data') + my_sr_document = dcmread( + str(data_dir.joinpath('test_files', 'sr_document.dcm')) + ) + content_sequence = my_sr_document.ContentSequence[0] + concept_name_code_sequence = content_sequence.ConceptNameCodeSequence[0] + # remove existing code value + del concept_name_code_sequence.CodeValue + # add URN Code Value + URN_code_value = "http://example.com/my_urn_value" + concept_name_code_sequence.URNCodeValue = URN_code_value + items = find_content_items(my_sr_document) + assert len(items) == 8 + + def test_find_content_items_with_long_code_value(self): + file_path = Path(__file__) + data_dir = file_path.parent.parent.joinpath('data') + my_sr_document = dcmread( + str(data_dir.joinpath('test_files', 'sr_document.dcm')) + ) + content_sequence = my_sr_document.ContentSequence[0] + concept_name_code_sequence = content_sequence.ConceptNameCodeSequence[0] + # remove existing code value + del concept_name_code_sequence.CodeValue + # add Long Code Value + long_code_value = "Test_A_Long_Code_Value" + concept_name_code_sequence.LongCodeValue = long_code_value + items = find_content_items(my_sr_document) + assert len(items) == 8 + def test_find_content_items_filtered_by_name(self): items = find_content_items( self._sr_document,