dcm_dict 0.29.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +156 -0
- data/COPYING +674 -0
- data/LICENSE +22 -0
- data/README.md +327 -0
- data/Rakefile +36 -0
- data/bin/dcm_dict_converter.rb +194 -0
- data/lib/dcm_dict.rb +46 -0
- data/lib/dcm_dict/dictionary/base_dictionary.rb +47 -0
- data/lib/dcm_dict/dictionary/base_record.rb +62 -0
- data/lib/dcm_dict/dictionary/data_element_dictionary.rb +117 -0
- data/lib/dcm_dict/dictionary/data_element_record.rb +93 -0
- data/lib/dcm_dict/dictionary/uid_dictionary.rb +82 -0
- data/lib/dcm_dict/dictionary/uid_record.rb +48 -0
- data/lib/dcm_dict/encoder/data_to_code.rb +79 -0
- data/lib/dcm_dict/error/dictionary_error.rb +30 -0
- data/lib/dcm_dict/ext/object_extension.rb +38 -0
- data/lib/dcm_dict/refine/array_refine.rb +34 -0
- data/lib/dcm_dict/refine/data_element_refine.rb +37 -0
- data/lib/dcm_dict/refine/internal/array_refine_internal.rb +97 -0
- data/lib/dcm_dict/refine/internal/hash_refine_internal.rb +71 -0
- data/lib/dcm_dict/refine/internal/string_refine_internal.rb +135 -0
- data/lib/dcm_dict/refine/string_refine.rb +35 -0
- data/lib/dcm_dict/refine/symbol_refine.rb +34 -0
- data/lib/dcm_dict/refine/uid_refine.rb +36 -0
- data/lib/dcm_dict/rubies/rb_ext.rb +32 -0
- data/lib/dcm_dict/source_data/data_elements_data.rb +4945 -0
- data/lib/dcm_dict/source_data/detached_data.rb +67 -0
- data/lib/dcm_dict/source_data/uid_values_data.rb +467 -0
- data/lib/dcm_dict/version.rb +27 -0
- data/lib/dcm_dict/xml/constant.rb +38 -0
- data/lib/dcm_dict/xml/field_data.rb +47 -0
- data/lib/dcm_dict/xml/nokogiri_tool.rb +108 -0
- data/lib/dcm_dict/xml/rexml_tool.rb +105 -0
- data/lib/dcm_dict/xml/tag_field_data.rb +96 -0
- data/lib/dcm_dict/xml/uid_field_data.rb +60 -0
- data/lib/dcm_dict/xml/xml_tool.rb +47 -0
- data/spec/data_element_sample_spec_helper.rb +203 -0
- data/spec/data_element_shared_example_spec_helper.rb +57 -0
- data/spec/dcm_dict/dictionary/data_element_dictionary_spec.rb +76 -0
- data/spec/dcm_dict/dictionary/data_element_record_spec.rb +138 -0
- data/spec/dcm_dict/dictionary/uid_dictionary_spec.rb +82 -0
- data/spec/dcm_dict/dictionary/uid_record_spec.rb +53 -0
- data/spec/dcm_dict/encoder/data_to_code_spec.rb +109 -0
- data/spec/dcm_dict/ext/object_extension_spec.rb +53 -0
- data/spec/dcm_dict/refine/array_refine_spec.rb +60 -0
- data/spec/dcm_dict/refine/internal/array_refine_internal_spec.rb +98 -0
- data/spec/dcm_dict/refine/internal/hash_refine_internal_spec.rb +64 -0
- data/spec/dcm_dict/refine/internal/string_refine_internal_spec.rb +228 -0
- data/spec/dcm_dict/refine/string_refine_spec.rb +87 -0
- data/spec/dcm_dict/refine/symbol_refine_spec.rb +41 -0
- data/spec/dcm_dict/rubies/rb_ext_spec.rb +46 -0
- data/spec/dcm_dict/source_data/data_elements_data_spec.rb +40 -0
- data/spec/dcm_dict/source_data/detached_data_spec.rb +55 -0
- data/spec/dcm_dict/source_data/uid_values_data_spec.rb +37 -0
- data/spec/dcm_dict/version_spec.rb +30 -0
- data/spec/dcm_dict/xml/tag_field_data_spec.rb +62 -0
- data/spec/dcm_dict/xml/uid_field_data_spec.rb +60 -0
- data/spec/dictionary_shared_example_spec_helper.rb +118 -0
- data/spec/refine_shared_example_spec_helper.rb +54 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/xml_sample_spec_helper.rb +567 -0
- metadata +216 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
module DcmDict
|
25
|
+
VERSION = "0.29.0"
|
26
|
+
DICOM_DOC_VERSION = "2020c"
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
module DcmDict
|
25
|
+
module XML
|
26
|
+
DataElementNodeSetIdx = { tag_ps: 0,
|
27
|
+
tag_name: 1,
|
28
|
+
tag_key: 2,
|
29
|
+
tag_vr: 3,
|
30
|
+
tag_vm: 4,
|
31
|
+
tag_note: 5 }.freeze
|
32
|
+
|
33
|
+
UidNodeSetIdx = { uid_value: 0,
|
34
|
+
uid_name: 1,
|
35
|
+
uid_type: 2}.freeze
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
module DcmDict
|
25
|
+
module XML
|
26
|
+
|
27
|
+
# Base class to manage xml data
|
28
|
+
class FieldData
|
29
|
+
using DcmDict::Refine::Internal::StringRefineInternal
|
30
|
+
|
31
|
+
# Initialize object using +extract_proc+ as proc to extract data from xml element
|
32
|
+
def initialize(extract_proc)
|
33
|
+
@extract_proc = extract_proc
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def extract_multiple_data(key, sep)
|
38
|
+
extract_content_data(key).split(sep)
|
39
|
+
end
|
40
|
+
|
41
|
+
def extract_content_data(key)
|
42
|
+
data = @extract_proc.call(key)
|
43
|
+
data ? data.dcm_unspace : ''
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
|
25
|
+
module DcmDict
|
26
|
+
module XML
|
27
|
+
@@nokogiri_enable = false
|
28
|
+
|
29
|
+
begin
|
30
|
+
#raise LoadError.new "Simulate LoadError to disable Nokogiri"
|
31
|
+
require 'nokogiri'
|
32
|
+
@@nokogiri_enable = true
|
33
|
+
rescue LoadError
|
34
|
+
end
|
35
|
+
|
36
|
+
# Check for Nokogiri gem
|
37
|
+
def self.nokogiri_enable?
|
38
|
+
@@nokogiri_enable
|
39
|
+
end
|
40
|
+
|
41
|
+
if @@nokogiri_enable
|
42
|
+
module NokogiriTool
|
43
|
+
|
44
|
+
# Extract data element data from a table row using +xml_tr_string+ as source string
|
45
|
+
def self.extract_data_element_field_from_xml_tr(xml_tr_string)
|
46
|
+
nodeset = extract_nokogiri_nodeset(xml_tr_string)
|
47
|
+
extract_data_element_field_from_tr_set(nodeset)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Extract data element data from xml table row using +trset+ (NodeSet) as source
|
51
|
+
def self.extract_data_element_field_from_tr_set(trset)
|
52
|
+
proc = tag_field_extract_proc(trset)
|
53
|
+
TagFieldData.new(proc).data_element_data
|
54
|
+
end
|
55
|
+
|
56
|
+
# Extract uid data from a table row using +xml_tr_string+ as source string
|
57
|
+
def self.extract_uid_field_from_xml_tr(xml_tr_string)
|
58
|
+
nodeset = extract_nokogiri_nodeset(xml_tr_string)
|
59
|
+
extract_uid_field_from_tr_set(nodeset)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Extract uid data from a table row using +trset+ (NodeSet) as source
|
63
|
+
def self.extract_uid_field_from_tr_set(trset)
|
64
|
+
proc = uid_field_extract_proc(trset)
|
65
|
+
UidFieldData.new(proc).uid_data
|
66
|
+
end
|
67
|
+
|
68
|
+
# Create XML root object from xml source string +xml_string+
|
69
|
+
def self.create_xml_doc(xml_string)
|
70
|
+
Nokogiri::XML(xml_string)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Calls the given block from +doc+ once for each 'table row' identified by +xpath+
|
74
|
+
def self.each_tr_set(doc, xpath)
|
75
|
+
alltr = doc.xpath(xpath)
|
76
|
+
alltr.each do |tr|
|
77
|
+
trset = tr.xpath('xmlns:td')
|
78
|
+
yield trset if block_given?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
def self.tag_field_extract_proc(node_set)
|
84
|
+
make_nokogiri_proc(node_set, DataElementNodeSetIdx)
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.uid_field_extract_proc(node_set)
|
88
|
+
make_nokogiri_proc(node_set, UidNodeSetIdx)
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.make_nokogiri_proc(node_set, node_set_idx)
|
92
|
+
Proc.new do |key|
|
93
|
+
idx = node_set_idx[key]
|
94
|
+
node_set[idx] ? node_set[idx].content.gsub(/ {2,}/, '') : ''
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.extract_nokogiri_nodeset(xml_tr_string)
|
99
|
+
doc = create_xml_doc(xml_tr_string)
|
100
|
+
each_tr_set(doc, '//xmlns:tr') do |tdset|
|
101
|
+
return tdset
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require "rexml/document"
|
25
|
+
|
26
|
+
module DcmDict
|
27
|
+
module XML
|
28
|
+
|
29
|
+
module RexmlTool
|
30
|
+
|
31
|
+
# Extract data element data from a table row using +xml_tr_string+ as source string
|
32
|
+
def self.extract_data_element_field_from_xml_tr(xml_tr_string)
|
33
|
+
nodeset = extract_rexml_nodeset(xml_tr_string)
|
34
|
+
extract_data_element_field_from_tr_set(nodeset)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Extract data element data from xml table row using +trset+ (NodeSet) as source
|
38
|
+
def self.extract_data_element_field_from_tr_set(trset)
|
39
|
+
proc = tag_field_extract_proc(trset)
|
40
|
+
TagFieldData.new(proc).data_element_data
|
41
|
+
end
|
42
|
+
|
43
|
+
# Extract uid data from a table row using +xml_tr_string+ as source string
|
44
|
+
def self.extract_uid_field_from_xml_tr(xml_tr_string)
|
45
|
+
nodeset = extract_rexml_nodeset(xml_tr_string)
|
46
|
+
extract_uid_field_from_tr_set(nodeset)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Extract uid data from a table row using +trset+ (XML Element) as source
|
50
|
+
def self.extract_uid_field_from_tr_set(trset)
|
51
|
+
proc = uid_field_extract_proc(trset)
|
52
|
+
UidFieldData.new(proc).uid_data
|
53
|
+
end
|
54
|
+
|
55
|
+
# Create XML root object from xml source string +xml_string+
|
56
|
+
def self.create_xml_doc(xml_string)
|
57
|
+
REXML::Document.new(xml_string)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Calls the given block from +doc+ once for each 'table row' identified by +xpath+
|
61
|
+
def self.each_tr_set(doc, xpath)
|
62
|
+
alltr = REXML::XPath.match(doc, xpath)
|
63
|
+
alltr.each do |tr|
|
64
|
+
trset = tr.get_elements('xmlns:td')
|
65
|
+
yield trset if block_given?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
def self.tag_field_extract_proc(node_set)
|
71
|
+
make_rexml_proc(node_set, DataElementNodeSetIdx)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.uid_field_extract_proc(node_set)
|
75
|
+
make_rexml_proc(node_set, UidNodeSetIdx)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.make_rexml_proc(node_set, node_set_idx)
|
79
|
+
Proc.new do |key|
|
80
|
+
element = node_set[node_set_idx[key]]
|
81
|
+
field = ''
|
82
|
+
if element
|
83
|
+
element.each_element_with_text do |txt1|
|
84
|
+
field << "\n" unless field.nil_or_empty?
|
85
|
+
txt1.each_element_with_text do |txt2|
|
86
|
+
field << txt2.texts.map(&:value).join('')
|
87
|
+
end
|
88
|
+
field << txt1.texts.map(&:value).join('')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
field
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.extract_rexml_nodeset(xml_tr_string)
|
96
|
+
doc = create_xml_doc(xml_tr_string)
|
97
|
+
each_tr_set(doc, "//xmlns:tr") do |tdset|
|
98
|
+
return tdset
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
module DcmDict
|
25
|
+
module XML
|
26
|
+
MultiFieldSeparator = ' or '.freeze
|
27
|
+
DefaultMultiTagValue = '2'.freeze
|
28
|
+
|
29
|
+
# Class to handle data element data
|
30
|
+
class TagFieldData < FieldData
|
31
|
+
using DcmDict::Refine::Internal::StringRefineInternal
|
32
|
+
using DcmDict::Refine::Internal::HashRefineInternal
|
33
|
+
|
34
|
+
# Initialize object using +extract_proc+ as proc to extract data from xml element
|
35
|
+
def initialize(extract_proc)
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
# Extract and build data element data
|
40
|
+
def data_element_data
|
41
|
+
extract_base_data()
|
42
|
+
@data.check_base_data_tag_field!
|
43
|
+
extend_base_data()
|
44
|
+
@data
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def extract_base_data()
|
49
|
+
@data = { :tag_ps => extract_content_data(:tag_ps),
|
50
|
+
:tag_name => extract_content_data(:tag_name),
|
51
|
+
:tag_key => extract_content_data(:tag_key),
|
52
|
+
:tag_vr => extract_tag_vr(),
|
53
|
+
:tag_vm => extract_tag_vm(),
|
54
|
+
:tag_note => extract_content_data(:tag_note) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def extract_tag_vr()
|
58
|
+
extract_multiple_data(:tag_vr, MultiFieldSeparator).map(&:to_sym)
|
59
|
+
end
|
60
|
+
|
61
|
+
def extract_tag_vm()
|
62
|
+
extract_multiple_data(:tag_vm, MultiFieldSeparator)
|
63
|
+
end
|
64
|
+
|
65
|
+
def extend_base_data
|
66
|
+
@data[:tag_str] = extract_tag_str_from_data
|
67
|
+
@data[:tag_sym] = extract_tag_sym_from_data
|
68
|
+
@data[:tag_ndm] = extract_tag_ndm_from_data
|
69
|
+
@data[:tag_ary] = extract_tag_ary_from_data
|
70
|
+
@data[:tag_multiple] = data_with_multiple_tag?
|
71
|
+
end
|
72
|
+
|
73
|
+
def extract_tag_str_from_data
|
74
|
+
@data[:tag_ps].gsub(/[xX|]/, DefaultMultiTagValue)
|
75
|
+
end
|
76
|
+
|
77
|
+
def data_with_multiple_tag?
|
78
|
+
@data[:tag_ps].index(/[xX|]/) ? true : false
|
79
|
+
end
|
80
|
+
|
81
|
+
def extract_tag_ary_from_data
|
82
|
+
@data[:tag_str].to_tag_ary
|
83
|
+
end
|
84
|
+
|
85
|
+
def extract_tag_ndm_from_data
|
86
|
+
@data[:tag_str].to_tag_ndm
|
87
|
+
end
|
88
|
+
|
89
|
+
def extract_tag_sym_from_data
|
90
|
+
@data[:tag_key].tag_key_to_sym
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014-2020 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
module DcmDict
|
25
|
+
module XML
|
26
|
+
|
27
|
+
# Class to handle uid data
|
28
|
+
class UidFieldData < FieldData
|
29
|
+
using DcmDict::Refine::Internal::StringRefineInternal
|
30
|
+
|
31
|
+
MISSING_NAME_VALUE = "(Retired)"
|
32
|
+
|
33
|
+
# Initialize object using +extract_proc+ as proc to extract data from xml element
|
34
|
+
def initialize(extract_proc)
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
# Extract and build uid data
|
39
|
+
def uid_data
|
40
|
+
extract_base_data
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def extract_base_data
|
45
|
+
value = extract_content_data(:uid_value)
|
46
|
+
type = extract_content_data(:uid_type).uid_type_to_sym
|
47
|
+
name = check_uid_name_for(extract_content_data(:uid_name), value, type)
|
48
|
+
{ uid_value: value,
|
49
|
+
uid_name: name,
|
50
|
+
uid_type: type }
|
51
|
+
end
|
52
|
+
|
53
|
+
# patch for 2016a source data ...
|
54
|
+
def check_uid_name_for(name, value, type)
|
55
|
+
name = "#{value} #{MISSING_NAME_VALUE}" if (name == MISSING_NAME_VALUE)
|
56
|
+
name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|