dcm_dict 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +156 -0
  3. data/COPYING +674 -0
  4. data/LICENSE +22 -0
  5. data/README.md +327 -0
  6. data/Rakefile +36 -0
  7. data/bin/dcm_dict_converter.rb +194 -0
  8. data/lib/dcm_dict.rb +46 -0
  9. data/lib/dcm_dict/dictionary/base_dictionary.rb +47 -0
  10. data/lib/dcm_dict/dictionary/base_record.rb +62 -0
  11. data/lib/dcm_dict/dictionary/data_element_dictionary.rb +117 -0
  12. data/lib/dcm_dict/dictionary/data_element_record.rb +93 -0
  13. data/lib/dcm_dict/dictionary/uid_dictionary.rb +82 -0
  14. data/lib/dcm_dict/dictionary/uid_record.rb +48 -0
  15. data/lib/dcm_dict/encoder/data_to_code.rb +79 -0
  16. data/lib/dcm_dict/error/dictionary_error.rb +30 -0
  17. data/lib/dcm_dict/ext/object_extension.rb +38 -0
  18. data/lib/dcm_dict/refine/array_refine.rb +34 -0
  19. data/lib/dcm_dict/refine/data_element_refine.rb +37 -0
  20. data/lib/dcm_dict/refine/internal/array_refine_internal.rb +97 -0
  21. data/lib/dcm_dict/refine/internal/hash_refine_internal.rb +71 -0
  22. data/lib/dcm_dict/refine/internal/string_refine_internal.rb +135 -0
  23. data/lib/dcm_dict/refine/string_refine.rb +35 -0
  24. data/lib/dcm_dict/refine/symbol_refine.rb +34 -0
  25. data/lib/dcm_dict/refine/uid_refine.rb +36 -0
  26. data/lib/dcm_dict/rubies/rb_ext.rb +32 -0
  27. data/lib/dcm_dict/source_data/data_elements_data.rb +4945 -0
  28. data/lib/dcm_dict/source_data/detached_data.rb +67 -0
  29. data/lib/dcm_dict/source_data/uid_values_data.rb +467 -0
  30. data/lib/dcm_dict/version.rb +27 -0
  31. data/lib/dcm_dict/xml/constant.rb +38 -0
  32. data/lib/dcm_dict/xml/field_data.rb +47 -0
  33. data/lib/dcm_dict/xml/nokogiri_tool.rb +108 -0
  34. data/lib/dcm_dict/xml/rexml_tool.rb +105 -0
  35. data/lib/dcm_dict/xml/tag_field_data.rb +96 -0
  36. data/lib/dcm_dict/xml/uid_field_data.rb +60 -0
  37. data/lib/dcm_dict/xml/xml_tool.rb +47 -0
  38. data/spec/data_element_sample_spec_helper.rb +203 -0
  39. data/spec/data_element_shared_example_spec_helper.rb +57 -0
  40. data/spec/dcm_dict/dictionary/data_element_dictionary_spec.rb +76 -0
  41. data/spec/dcm_dict/dictionary/data_element_record_spec.rb +138 -0
  42. data/spec/dcm_dict/dictionary/uid_dictionary_spec.rb +82 -0
  43. data/spec/dcm_dict/dictionary/uid_record_spec.rb +53 -0
  44. data/spec/dcm_dict/encoder/data_to_code_spec.rb +109 -0
  45. data/spec/dcm_dict/ext/object_extension_spec.rb +53 -0
  46. data/spec/dcm_dict/refine/array_refine_spec.rb +60 -0
  47. data/spec/dcm_dict/refine/internal/array_refine_internal_spec.rb +98 -0
  48. data/spec/dcm_dict/refine/internal/hash_refine_internal_spec.rb +64 -0
  49. data/spec/dcm_dict/refine/internal/string_refine_internal_spec.rb +228 -0
  50. data/spec/dcm_dict/refine/string_refine_spec.rb +87 -0
  51. data/spec/dcm_dict/refine/symbol_refine_spec.rb +41 -0
  52. data/spec/dcm_dict/rubies/rb_ext_spec.rb +46 -0
  53. data/spec/dcm_dict/source_data/data_elements_data_spec.rb +40 -0
  54. data/spec/dcm_dict/source_data/detached_data_spec.rb +55 -0
  55. data/spec/dcm_dict/source_data/uid_values_data_spec.rb +37 -0
  56. data/spec/dcm_dict/version_spec.rb +30 -0
  57. data/spec/dcm_dict/xml/tag_field_data_spec.rb +62 -0
  58. data/spec/dcm_dict/xml/uid_field_data_spec.rb +60 -0
  59. data/spec/dictionary_shared_example_spec_helper.rb +118 -0
  60. data/spec/refine_shared_example_spec_helper.rb +54 -0
  61. data/spec/spec_helper.rb +42 -0
  62. data/spec/xml_sample_spec_helper.rb +567 -0
  63. metadata +216 -0
@@ -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
+ #require_relative 'constant'
25
+ require_relative 'rexml_tool'
26
+ require_relative 'nokogiri_tool'
27
+
28
+ module DcmDict
29
+ module XML
30
+
31
+ # Main tool to handle xml data for uid and data element
32
+ module XmlTool
33
+ class << self
34
+ private
35
+ def xml_tool
36
+ XML.nokogiri_enable? ? NokogiriTool : RexmlTool
37
+ end
38
+
39
+ def method_missing(*args, &block)
40
+ m = args.shift
41
+ xml_tool.send(m, *args, &block)
42
+ end
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,203 @@
1
+ # coding: utf-8
2
+ #
3
+ # Copyright (C) 2014-2020 Enrico Rivarola
4
+ #
5
+ # This file is part of DcmDict gem (dcm_dict).
6
+ #
7
+ # DcmDict is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # DcmDict is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+ # This software has neither been tested nor approved for clinical use
21
+ # or for incorporation in a medical device.
22
+ # It is the redistributor's or user's responsibility to comply with any
23
+ # applicable local, state, national or international regulations.
24
+ #
25
+ require 'spec_helper'
26
+ module DataElementSampleSpecHelper
27
+ def self.private_creator_sample
28
+ {
29
+ [17,5] => {tag_ps: '(0011,0005)', tag_str: '(0011,0005)', tag_ary: [0x0011,0x0005],
30
+ tag_sym: :private_creator, tag_ndm: '00110005', tag_name: 'Private Creator',
31
+ tag_key: 'PrivateCreator', tag_vr: [:LO], tag_vm: ['1'], tag_note: 'Dummy Record',
32
+ tag_multiple: false},
33
+ '(0011,0005)' => {tag_ps: '(0011,0005)', tag_str: '(0011,0005)', tag_ary: [0x0011,0x0005],
34
+ tag_sym: :private_creator, tag_ndm: '00110005', tag_name: 'Private Creator',
35
+ tag_key: 'PrivateCreator', tag_vr: [:LO], tag_vm: ['1'], tag_note: 'Dummy Record',
36
+ tag_multiple: false},
37
+ '00110005' => {tag_ps: '(0011,0005)', tag_str: '(0011,0005)', tag_ary: [0x0011,0x0005],
38
+ tag_sym: :private_creator, tag_ndm: '00110005', tag_name: 'Private Creator',
39
+ tag_key: 'PrivateCreator', tag_vr: [:LO], tag_vm: ['1'], tag_note: 'Dummy Record',
40
+ tag_multiple: false}
41
+ }
42
+ end
43
+
44
+ def self.unknown_sample
45
+ {
46
+ [17,512] => {tag_ps: '(0011,0200)', tag_str: '(0011,0200)', tag_ary: [0x0011,0x0200],
47
+ tag_sym: :unknown_tag, tag_ndm: '00110200', tag_name: 'Unknown Tag',
48
+ tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
49
+ [0x4444,0x1234] => {tag_ps: '(4444,1234)', tag_str: '(4444,1234)', tag_ary: [0x4444,0x1234],
50
+ tag_sym: :unknown_tag, tag_ndm: '44441234', tag_name: 'Unknown Tag',
51
+ tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
52
+ '(4444,1234)' => {tag_ps: '(4444,1234)', tag_str: '(4444,1234)', tag_ary: [0x4444,0x1234],
53
+ tag_sym: :unknown_tag, tag_ndm: '44441234', tag_name: 'Unknown Tag',
54
+ tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
55
+ '44441234' => {tag_ps: '(4444,1234)', tag_str: '(4444,1234)', tag_ary: [0x4444,0x1234],
56
+ tag_sym: :unknown_tag, tag_ndm: '44441234', tag_name: 'Unknown Tag',
57
+ tag_key: 'UnknownTag', tag_vr: [:UN], tag_vm: ['1'], tag_note: 'Dummy Record', tag_multiple: false},
58
+ }
59
+ end
60
+
61
+ def self.known_group_length_sample
62
+ {
63
+ [0,0] => { tag_ps: '(0000,0000)', tag_name: "Command Group Length", tag_key: 'CommandGroupLength',
64
+ tag_vr: [:UL], tag_vm: ["1"], tag_str: '(0000,0000)', tag_sym: :command_group_length,
65
+ tag_ndm: '00000000', tag_ary: [0, 0], tag_multiple: false,
66
+ tag_note: 'The even number of bytes from the end of the value field to the beginning of the next group.'}
67
+ }
68
+ end
69
+
70
+ def self.standard_sample
71
+ {
72
+ [0x0018, 0x9323] => { tag_ps: '(0018,9323)', tag_name: "Exposure Modulation Type", tag_key: 'ExposureModulationType',
73
+ tag_vr: [:CS], tag_vm: ["1-n"], tag_str: '(0018,9323)', tag_sym: :exposure_modulation_type,
74
+ tag_ndm: '00189323', tag_ary: [0x0018, 0x9323], tag_multiple: false,
75
+ tag_note: ''},
76
+ [0x3006, 0x0033] => { tag_ps: '(3006,0033)', tag_name: "RT ROI Relationship", tag_key: 'RTROIRelationship',
77
+ tag_vr: [:CS], tag_vm: ["1"], tag_str: '(3006,0033)', tag_sym: :rt_roi_relationship,
78
+ tag_ndm: '30060033', tag_ary: [0x3006, 0x0033], tag_multiple: false,
79
+ tag_note: ''},
80
+ [0x3006, 0x00B9] => { tag_ps: '(3006,00B9)', tag_name: "Additional RT ROI Identification Code Sequence", tag_key: 'AdditionalRTROIIdentificationCodeSequence',
81
+ tag_vr: [:SQ], tag_vm: ["1"], tag_str: '(3006,00B9)', tag_sym: :additional_rt_roi_identification_code_sequence,
82
+ tag_ndm: '300600B9', tag_ary: [0x3006, 0x00B9], tag_multiple: false,
83
+ tag_note: 'RET (2016c)'},
84
+ [0x4010, 0x1019] => { tag_ps: '(4010,1019)', tag_name: "Z Effective", tag_key: 'ZEffective',
85
+ tag_vr: [:FL], tag_vm: ["1"], tag_str: '(4010,1019)', tag_sym: :z_effective,
86
+ tag_ndm: '40101019', tag_ary: [0x4010, 0x1019], tag_multiple: false,
87
+ tag_note: 'DICOS'},
88
+ [0x300A, 0x0434] => { tag_ps: '(300A,0434)', tag_name: "Applicator Opening X", tag_key: 'ApplicatorOpeningX',
89
+ tag_vr: [:FL], tag_vm: ["1"], tag_str: '(300A,0434)', tag_sym: :applicator_opening_x,
90
+ tag_ndm: '300A0434', tag_ary: [0x300A, 0x0434], tag_multiple: false,
91
+ tag_note: ''},
92
+ [0x3004, 0x0062] => { tag_ps: '(3004,0062)', tag_name: "DVH ROI Contribution Type", tag_key: 'DVHROIContributionType',
93
+ tag_vr: [:CS], tag_vm: ["1"], tag_str: '(3004,0062)', tag_sym: :dvh_roi_contribution_type,
94
+ tag_ndm: '30040062', tag_ary: [0x3004, 0x0062], tag_multiple: false,
95
+ tag_note: ''},
96
+ [0x2020, 0x0140] => { tag_ps: '(2020,0140)', tag_name: "Referenced VOI LUT Box Sequence", tag_key: 'ReferencedVOILUTBoxSequence',
97
+ tag_vr: [:SQ], tag_vm: ["1"], tag_str: '(2020,0140)', tag_sym: :referenced_voi_lut_box_sequence,
98
+ tag_ndm: '20200140', tag_ary: [0x2020, 0x0140], tag_multiple: false,
99
+ tag_note: 'RET (1998)'},
100
+ [0x0010, 0x1000] => { tag_ps: '(0010,1000)', tag_name: "Other Patient IDs", tag_key: 'OtherPatientIDs',
101
+ tag_vr: [:LO], tag_vm: ["1-n"], tag_str: '(0010,1000)', tag_sym: :other_patient_ids,
102
+ tag_ndm: '00101000', tag_ary: [0x0010,0x1000], tag_multiple: false,
103
+ tag_note: 'RET (2017a)'},
104
+ [0x0018, 0x9504] => { tag_ps: '(0018,9504)', tag_name: "X-Ray 3D Frame Type Sequence", tag_key: 'XRay3DFrameTypeSequence',
105
+ tag_vr: [:SQ], tag_vm: ["1"], tag_str: '(0018,9504)', tag_sym: :x_ray_3d_frame_type_sequence,
106
+ tag_ndm: '00189504', tag_ary: [0x0018,0x9504], tag_multiple: false,
107
+ tag_note: ''},
108
+ [0x0052,0x0030] => { tag_ps: '(0052,0030)', tag_name: "OCT Z Offset Correction", tag_key: 'OCTZOffsetCorrection',
109
+ tag_vr: [:SS], tag_vm: ["1"], tag_str: '(0052,0030)', tag_sym: :oct_z_offset_correction,
110
+ tag_ndm: '00520030', tag_ary: [0x0052,0x0030], tag_multiple: false,
111
+ tag_note: ''},
112
+ [0x0040,0xE025] => { tag_ps: '(0040,E025)', tag_name: "WADO-RS Retrieval Sequence", tag_key: 'WADORSRetrievalSequence',
113
+ tag_vr: [:SQ], tag_vm: ["1"], tag_str: '(0040,E025)', tag_sym: :wado_rs_retrieval_sequence,
114
+ tag_ndm: '0040E025', tag_ary: [0x0040,0xE025], tag_multiple: false,
115
+ tag_note: ''},
116
+ [0x0040,0x4072] => { tag_ps: '(0040,4072)', tag_name: "STOW-RS Storage Sequence", tag_key: 'STOWRSStorageSequence',
117
+ tag_vr: [:SQ], tag_vm: ["1"], tag_str: '(0040,4072)', tag_sym: :stow_rs_storage_sequence,
118
+ tag_ndm: '00404072', tag_ary: [0x0040,0x4072], tag_multiple: false,
119
+ tag_note: ''},
120
+ [0x0028,0x7018] => { tag_ps: '(0028,7018)', tag_name: "CIExy White Point", tag_key: 'CIExyWhitePoint',
121
+ tag_vr: [:FL], tag_vm: ["2"], tag_str: '(0028,7018)', tag_sym: :ciexy_white_point,
122
+ tag_ndm: '00287018', tag_ary: [0x0028,0x7018], tag_multiple: false,
123
+ tag_note: ''},
124
+ [0x0028,0x140F] => { tag_ps: '(0028,140F)', tag_name: "RGB LUT Transfer Function", tag_key: 'RGBLUTTransferFunction',
125
+ tag_vr: [:CS], tag_vm: ["1"], tag_str: '(0028,140F)', tag_sym: :rgb_lut_transfer_function,
126
+ tag_ndm: '0028140F', tag_ary: [0x0028,0x140F], tag_multiple: false,
127
+ tag_note: ''},
128
+ [0x0018,0x9942] => { tag_ps: '(0018,9942)', tag_name: "CTDIvol Notification Trigger", tag_key: 'CTDIvolNotificationTrigger',
129
+ tag_vr: [:FD], tag_vm: ["1"], tag_str: '(0018,9942)', tag_sym: :ctdi_vol_notification_trigger,
130
+ tag_ndm: '00189942', tag_ary: [0x0018,0x9942], tag_multiple: false,
131
+ tag_note: ''},
132
+ [0x0018,0x9412] => { tag_ps: '(0018,9412)', tag_name: "XA/XRF Frame Characteristics Sequence", tag_key: 'XAXRFFrameCharacteristicsSequence',
133
+ tag_vr: [:SQ], tag_vm: ["1"], tag_str: '(0018,9412)', tag_sym: :xa_xrf_frame_characteristics_sequence,
134
+ tag_ndm: '00189412', tag_ary: [0x0018,0x9412], tag_multiple: false,
135
+ tag_note: ''},
136
+ [0x0018,0x8151] => { tag_ps: '(0018,8151)', tag_name: "X-Ray Tube Current in µA", tag_key: 'XRayTubeCurrentInuA',
137
+ tag_vr: [:DS], tag_vm: ["1"], tag_str: '(0018,8151)', tag_sym: :x_ray_tube_current_in_ua,
138
+ tag_ndm: '00188151', tag_ary: [0x0018,0x8151], tag_multiple: false,
139
+ tag_note: ''},
140
+ [0x0018,0x8150] => { tag_ps: '(0018,8150)', tag_name: "Exposure Time in µS", tag_key: 'ExposureTimeInuS',
141
+ tag_vr: [:DS], tag_vm: ["1"], tag_str: '(0018,8150)', tag_sym: :exposure_time_in_us,
142
+ tag_ndm: '00188150', tag_ary: [0x0018,0x8150], tag_multiple: false,
143
+ tag_note: ''},
144
+ [0x0018,0x1153] => { tag_ps: '(0018,1153)', tag_name: "Exposure in µAs", tag_key: 'ExposureInuAs',
145
+ tag_vr: [:IS], tag_vm: ["1"], tag_str: '(0018,1153)', tag_sym: :exposure_in_uas,
146
+ tag_ndm: '00181153', tag_ary: [0x0018,0x1153], tag_multiple: false,
147
+ tag_note: ''},
148
+ [0x0018,0x1318] => { tag_ps: '(0018,1318)', tag_name: "dB/dt", tag_key: 'dBdt',
149
+ tag_vr: [:DS], tag_vm: ["1"], tag_str: '(0018,1318)', tag_sym: :db_dt,
150
+ tag_ndm: '00181318', tag_ary: [0x0018,0x1318], tag_multiple: false,
151
+ tag_note: ''},
152
+ [0x0002,0x0027] => { tag_ps: '(0002,0027)', tag_name: "Sending Presentation Address", tag_key: 'SendingPresentationAddress',
153
+ tag_vr: [:UR], tag_vm: ["1"], tag_str: '(0002,0027)', tag_sym: :sending_presentation_address,
154
+ tag_ndm: '00020027', tag_ary: [0x0002,0x0027], tag_multiple: false,
155
+ tag_note: ''},
156
+ [0x3010,0x0096] => { tag_ps: '(3010,0096)', tag_name: "Radiation Source Coordinate System Pitch Angle",
157
+ tag_key: 'RadiationSourceCoordinateSystemPitchAngle', tag_vr: [:FD], tag_vm: ["1"], tag_str: '(3010,0096)',
158
+ tag_sym: :radiation_source_coordinate_system_pitch_angle, tag_ndm: '30100096',
159
+ tag_ary: [0x3010,0x0096], tag_multiple: false, tag_note: ''}
160
+ }
161
+ end
162
+
163
+ def self.unknown_group_length_sample
164
+ {
165
+ [16,0] => {tag_ps: '(0010,0000)', tag_str: '(0010,0000)', tag_ary: [0x0010,0x0000],
166
+ tag_sym: :group_length, tag_ndm: '00100000', tag_name: 'Group Length',
167
+ tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
168
+ tag_multiple: false},
169
+ [17,0] => {tag_ps: '(0011,0000)', tag_str: '(0011,0000)', tag_ary: [0x0011,0x0000],
170
+ tag_sym: :group_length, tag_ndm: '00110000', tag_name: 'Group Length',
171
+ tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',},
172
+ [0x4444,0x0000] => {tag_ps: '(4444,0000)', tag_str: '(4444,0000)', tag_ary: [0x4444,0x0000],
173
+ tag_sym: :group_length, tag_ndm: '44440000', tag_name: 'Group Length',
174
+ tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
175
+ tag_multiple: false},
176
+ '44440000' => {tag_ps: '(4444,0000)', tag_str: '(4444,0000)', tag_ary: [0x4444,0x0000],
177
+ tag_sym: :group_length, tag_ndm: '44440000', tag_name: 'Group Length',
178
+ tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
179
+ tag_multiple: false},
180
+ '(4444,0000)' => {tag_ps: '(4444,0000)', tag_str: '(4444,0000)', tag_ary: [0x4444,0x0000],
181
+ tag_sym: :group_length, tag_ndm: '44440000', tag_name: 'Group Length',
182
+ tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ['1'], tag_note: 'Dummy Record',
183
+ tag_multiple: false}
184
+ }
185
+ end
186
+
187
+ def self.multiple_tag_sample
188
+ {
189
+ # (60xx,0010) -> "Overlay Rows"
190
+ [0x60A2,0x0010] => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(60A2,0010)', tag_sym: :overlay_rows, tag_ndm: '60A20010', tag_ary: [0x60a2,0x0010], tag_multiple: true, tag_note: ''},
191
+ '60A20010' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(60A2,0010)', tag_sym: :overlay_rows, tag_ndm: '60A20010', tag_ary: [0x60a2,0x0010], tag_multiple: true, tag_note: ''},
192
+ '(60A2,0010)' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(60A2,0010)', tag_sym: :overlay_rows, tag_ndm: '60A20010', tag_ary: [0x60a2,0x0010], tag_multiple: true, tag_note: ''},
193
+ '(6022,0010)' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
194
+ 'OverlayRows' => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
195
+ [0x6022,0x0010] => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
196
+ [0x1010,0xa1b2] => { tag_ps: '(1010,XXXX)', tag_name: "Zonal Map", tag_key: 'ZonalMap', tag_vr: [:US], tag_vm: ["1-n"], tag_str: '(1010,A1B2)', tag_sym: :zonal_map, tag_ndm: '1010A1B2', tag_ary: [0x1010, 0xa1b2], tag_multiple: true, tag_note: 'RET (2007)'},
197
+ '(1010,A1B2)' => { tag_ps: '(1010,XXXX)', tag_name: "Zonal Map", tag_key: 'ZonalMap', tag_vr: [:US], tag_vm: ["1-n"], tag_str: '(1010,A1B2)', tag_sym: :zonal_map, tag_ndm: '1010A1B2', tag_ary: [0x1010, 0xa1b2], tag_multiple: true, tag_note: 'RET (2007)'},
198
+ '1010A1B2' => { tag_ps: '(1010,XXXX)', tag_name: "Zonal Map", tag_key: 'ZonalMap', tag_vr: [:US], tag_vm: ["1-n"], tag_str: '(1010,A1B2)', tag_sym: :zonal_map, tag_ndm: '1010A1B2', tag_ary: [0x1010, 0xa1b2], tag_multiple: true, tag_note: 'RET (2007)'},
199
+ '10100000' => { tag_ps: '(1010,0000)', tag_name: 'Group Length', tag_key: 'GroupLength', tag_vr: [:UL], tag_vm: ["1"], tag_str: '(1010,0000)', tag_sym: :group_length, tag_ndm: '10100000', tag_ary: [0x1010, 0x0000], tag_multiple: false, tag_note: 'Dummy Record'},
200
+ }
201
+ end
202
+
203
+ end
@@ -0,0 +1,57 @@
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
+ using DcmDict::Refine::ArrayRefine
25
+ using DcmDict::Refine::StringRefine
26
+ using DcmDict::Refine::SymbolRefine
27
+
28
+ RSpec.shared_examples "refinement for standard tag" do |tags, tag_proc|
29
+ describe "for standard tag" do
30
+ tags.each do |tag|
31
+ describe "as #{tag_proc.call(tag)}" do
32
+ obj = DcmDict::Dictionary::TheDataElementDictionary.record_at(tag)
33
+ DcmDict::Dictionary::DataElementMethod.each do |method|
34
+ expr = "#{tag_proc.call(tag)}.#{method.to_s}"
35
+ it "with #{expr} > #{obj.send(method).inspect}" do
36
+ value = eval(expr)
37
+ expect(value).to eq(obj.send(method))
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ RSpec.shared_examples "refinement for multiple tag" do |tag_data, tag_proc|
46
+ describe "for multiple tag" do
47
+ tag_data.each do |tag, data|
48
+ data.each do |key, exp_value|
49
+ expr = "#{tag_proc.call(tag)}.#{key}"
50
+ it "as #{expr} > #{exp_value.inspect}" do
51
+ value = eval(expr)
52
+ expect(value).to eq(exp_value)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,76 @@
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 'spec_helper'
25
+ require 'data_element_sample_spec_helper'
26
+
27
+ describe DcmDict::Dictionary::DataElementDictionary do
28
+
29
+ include_examples "Map all source data",
30
+ [:tag_ps, :tag_name, :tag_key, :tag_str, :tag_sym, :tag_ndm, :tag_ary],
31
+ DcmDict::SourceData::DataElementsData,
32
+ DcmDict::Dictionary::TheDataElementDictionary,
33
+ DcmDict::Dictionary::DataElementRecord,
34
+ [:tag_ps, :tag_name, :tag_key, :tag_vr, :tag_vm, :tag_str, :tag_sym,
35
+ :tag_ndm, :tag_ary, :tag_multiple, :tag_note]
36
+
37
+ DataElementSampleSpecHelper.unknown_group_length_sample.
38
+ merge(DataElementSampleSpecHelper.known_group_length_sample).
39
+ merge(DataElementSampleSpecHelper.private_creator_sample).
40
+ merge(DataElementSampleSpecHelper.standard_sample).
41
+ merge(DataElementSampleSpecHelper.unknown_sample).each do |tag, data|
42
+ include_examples "Handle specific record", "single tag",
43
+ tag, data, DcmDict::Dictionary::TheDataElementDictionary
44
+ end
45
+
46
+ DataElementSampleSpecHelper.multiple_tag_sample.each do |tag, data|
47
+ include_examples "Handle specific record", "multiple tag",
48
+ tag, data, DcmDict::Dictionary::TheDataElementDictionary
49
+ end
50
+
51
+ [nil,
52
+ 123455,
53
+ 'abracadabra',
54
+ Time.now,
55
+ [1234.5678, 1234]
56
+ ].each do |wrong_tag|
57
+ include_examples "Dictionary with wrong key",
58
+ wrong_tag,
59
+ [:tag_ps, :tag_name, :tag_key, :tag_vr, :tag_vm, :tag_str,
60
+ :tag_sym, :tag_ndm, :tag_ary, :tag_multiple, :tag_note],
61
+ DcmDict::Dictionary::TheDataElementDictionary
62
+ end
63
+
64
+ include_examples "Dictionary Data not modifiable",
65
+ '(0002,0010)', :tag_ps, DcmDict::Dictionary::TheDataElementDictionary
66
+
67
+ include_examples "Concurrency support",
68
+ '(0002,0010)',
69
+ DcmDict::Dictionary::TheDataElementDictionary,
70
+ { tag_ps: '(0002,0010)', tag_name: "Transfer Syntax UID",
71
+ tag_key: 'TransferSyntaxUID', tag_vr: [:UI], tag_vm: ["1"],
72
+ tag_str: '(0002,0010)', tag_sym: :transfer_syntax_uid,
73
+ tag_ndm: '00020010', tag_ary: [0x0002,0x0010],
74
+ tag_multiple: false, tag_note: ''}
75
+
76
+ end
@@ -0,0 +1,138 @@
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 'spec_helper'
25
+
26
+
27
+
28
+ describe DcmDict::Dictionary::DataElementRecord do
29
+ using DcmDict::Refine::Internal::ArrayRefineInternal
30
+
31
+ [
32
+ { tag_ps: '(0008,0010)',
33
+ tag_name: 'Recognition Code',
34
+ tag_key: 'RecognitionCode',
35
+ tag_vr: [:SH],
36
+ tag_vm: ['1'],
37
+ tag_note: 'RET',
38
+ tag_ary: [0x0008,0x0010],
39
+ tag_sym: :recognition_code,
40
+ tag_ndm: '00080010',
41
+ tag_str: '(0008,0010)',
42
+ tag_multiple: false},
43
+ { tag_ps: '(0008,1190)',
44
+ tag_name: "Retrieve URL",
45
+ tag_key: 'RetrieveURL',
46
+ tag_vr: [:UR],
47
+ tag_vm: ["1"],
48
+ tag_str: '(0008,1190)',
49
+ tag_sym: :retrieve_url,
50
+ tag_ndm: '00081190',
51
+ tag_ary: [0x0008,0x1190],
52
+ tag_multiple: false,
53
+ tag_note: ''},
54
+ { tag_ps: '(0008,0118)',
55
+ tag_name: "Long Code Value",
56
+ tag_key: 'LongCodeValue',
57
+ tag_vr: [:UC],
58
+ tag_vm: ["1"],
59
+ tag_str: '(0008,0118)',
60
+ tag_sym: :long_code_value,
61
+ tag_ndm: '00080118',
62
+ tag_ary: [0x0008,0x0118],
63
+ tag_multiple: false,
64
+ tag_note: ''}
65
+ ].each do |data|
66
+ it "Handle Data Element Data correctly (#{data[:tag_name].inspect}-#{data[:tag_str]}-#{data[:tag_vr]})" do
67
+ der = DcmDict::Dictionary::DataElementRecord.new(data)
68
+ expect(der.tag_ps).to eq(data[:tag_ps])
69
+ expect(der.tag_name).to eq(data[:tag_name])
70
+ expect(der.tag_keyword).to eq(data[:tag_key])
71
+ expect(der.tag_vr).to eq(data[:tag_vr])
72
+ expect(der.tag_vm).to eq(data[:tag_vm])
73
+ expect(der.tag_note).to eq(data[:tag_note])
74
+ expect(der.tag_ary).to eq(data[:tag_ary])
75
+ expect(der.tag).to eq(data[:tag_ary])
76
+ expect(der.tag_sym).to eq(data[:tag_sym])
77
+ expect(der.tag_ndm).to eq(data[:tag_ndm])
78
+ expect(der.tag_str).to eq(data[:tag_str])
79
+ expect(der.tag_multiple?).to eq(data[:tag_multiple])
80
+
81
+ data.each do |key, expected_val|
82
+ expect(der.send(key)).to eq(expected_val)
83
+ end
84
+
85
+ end
86
+
87
+ include_examples "Record handle methods correctly",
88
+ DcmDict::Dictionary::DataElementRecord.new(data),
89
+ data
90
+
91
+
92
+ it "Handle group and element with explicit method" do
93
+ der = DcmDict::Dictionary::DataElementRecord.new(data)
94
+ expect(der.tag_group).to eq(data[:tag_ary].tag_group_num)
95
+ expect(der.tag_element).to eq(data[:tag_ary].tag_element_num)
96
+ end
97
+
98
+ it "data should be not modifiable" do
99
+ der = DcmDict::Dictionary::DataElementRecord.new(data)
100
+ old_ps = der.tag_ps.dup
101
+ expect{der.tag_ps << 'aaa'}.to raise_error(RuntimeError)
102
+ expect(der.tag_ps).to eq(old_ps)
103
+ end
104
+
105
+ it "should extract multiple tag record only for specific tag" do
106
+ der = DcmDict::Dictionary::DataElementRecord.new(data)
107
+ mrec = der.extract_multiple_tag_record(data[:tag_ary])
108
+ expect(mrec).to be_nil
109
+ end
110
+
111
+ end
112
+
113
+ {
114
+ # { tag_ps: '(60xx,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
115
+ [
116
+ '(6068,0010)', '60680010', [0x6068,0x0010]
117
+ ] => {
118
+ :source_data => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6022,0010)', tag_sym: :overlay_rows, tag_ndm: '60220010', tag_ary: [24610, 16], tag_multiple: true, tag_note: ''},
119
+ :specific_data => { tag_ps: '(60XX,0010)', tag_name: "Overlay Rows", tag_key: 'OverlayRows', tag_vr: [:US], tag_vm: ["1"], tag_str: '(6068,0010)', tag_sym: :overlay_rows, tag_ndm: '60680010', tag_ary: [0x6068,0x0010], tag_multiple: true, tag_note: ''} }
120
+ }.each do |keys, multi_data|
121
+ it "check match for multiple tag definition from #{keys[0].inspect}" do
122
+ der = DcmDict::Dictionary::DataElementRecord.new(multi_data[:source_data])
123
+ keys.each do |key|
124
+ expect(der.send(:match_tag?, key)).to be_truthy
125
+ end
126
+ end
127
+
128
+ it "generate equivalent record for specific tag from #{keys[0].inspect}" do
129
+ der_multi = DcmDict::Dictionary::DataElementRecord.new(multi_data[:source_data])
130
+ der = der_multi.extract_multiple_tag_record(multi_data[:specific_data][:tag_ary])
131
+ multi_data[:specific_data].each do |key, val|
132
+ expect(der.send(key)).to eq(val)
133
+ end
134
+
135
+ end
136
+ end
137
+
138
+ end