open_ehr 0.9.3 → 0.9.4

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 (42) hide show
  1. data/History.txt +6 -0
  2. data/README.rdoc +6 -8
  3. data/VERSION +1 -1
  4. data/lib/open_ehr/am/archetype/constraint_model/primitive.rb +2 -2
  5. data/lib/open_ehr/am/archetype/ontology.rb +23 -28
  6. data/lib/open_ehr/am/archetype.rb +1 -1
  7. data/lib/open_ehr/parser/adl.rb +42 -4
  8. data/lib/open_ehr/parser/adl_grammar.tt +67 -42
  9. data/lib/open_ehr/parser/adl_parser.rb +1 -1
  10. data/lib/open_ehr/parser/cadl_grammar.tt +227 -61
  11. data/lib/open_ehr/parser/cadl_node.rb +1 -0
  12. data/lib/open_ehr/parser/dadl_grammar.tt +10 -10
  13. data/lib/open_ehr/parser/shared_token_grammar.tt +13 -13
  14. data/open_ehr.gemspec +14 -4
  15. data/spec/lib/open_ehr/am/archetype/archetype_spec.rb +1 -1
  16. data/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb +22 -13
  17. data/spec/lib/open_ehr/parser/adl14/adl-test-SOME_TYPE.generic_type_use_node.draft.adl +1 -1
  18. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_bindings.test.adl +1 -1
  19. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_internal_ref.test.adl +1 -1
  20. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_internal_ref2.test.adl +1 -1
  21. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_language.test.adl +1 -1
  22. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_language_no_accreditation.test.adl +1 -1
  23. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_language_order_of_translation_details.test.adl +1 -1
  24. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_ontology.test.adl +1 -1
  25. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.translations_author_language.test.adl +1 -1
  26. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.translations_language_author.test.adl +1 -1
  27. data/spec/lib/open_ehr/parser/adl_archetype_internal_ref2_spec.rb +42 -0
  28. data/spec/lib/open_ehr/parser/adl_archetype_internal_ref_spec.rb +125 -0
  29. data/spec/lib/open_ehr/parser/adl_archetype_internal_ref_with_generics_spec.rb +258 -0
  30. data/spec/lib/open_ehr/parser/adl_archetype_ontology_binding_spec.rb +98 -0
  31. data/spec/lib/open_ehr/parser/adl_archetype_ontology_spec.rb +42 -0
  32. data/spec/lib/open_ehr/parser/adl_description_spec.rb +13 -2
  33. data/spec/lib/open_ehr/parser/adl_language_no_accreditation_spec.rb +66 -0
  34. data/spec/lib/open_ehr/parser/adl_language_order_spec.rb +68 -0
  35. data/spec/lib/open_ehr/parser/adl_language_spec.rb +119 -0
  36. data/spec/lib/open_ehr/parser/adl_language_translation_author_language_spec.rb +50 -0
  37. data/spec/lib/open_ehr/parser/adl_language_translation_language_author_spec.rb +46 -0
  38. data/spec/lib/open_ehr/parser/adl_parser_spec.rb +2 -2
  39. data/spec/lib/open_ehr/parser/parser_spec_helper.rb +7 -0
  40. data/spec/lib/open_ehr/rm/common/resource/translation_details_spec.rb +4 -4
  41. metadata +49 -39
  42. data/Gemfile.lock +0 -85
@@ -4,20 +4,22 @@ include OpenEHR::RM::DataTypes::Text
4
4
 
5
5
  describe ArchetypeOntology do
6
6
  before(:each) do
7
- items = {:text => 'Archetype Concept', :desc => 'concept description'}
8
- term1 = ArchetypeTerm.new(:code => 'at0000', :items => items)
9
- items = {:text => 'Blood pressure'}
10
- term2 = ArchetypeTerm.new(:code => 'at0001', :items => items)
11
- term_definitions = {'ja' => [term1, term2], 'en' => [term1]}
12
- items = {:text => 'test', :description => 'test item'}
13
- term3 = ArchetypeTerm.new(:code => 'ac0000', :items => items)
14
- constraint_definitions = {'ja' => [term3]}
7
+ items = {'text' => 'Archetype Concept', 'desc' => 'concept description'}
8
+ term1 = {'at0000' => ArchetypeTerm.new(:code => 'at0000', :items => items)}
9
+ items = {'text' => 'Blood pressure'}
10
+ term2 = {'at0001' => ArchetypeTerm.new(:code => 'at0001', :items => items)}
11
+ term3 = {'at0002' => ArchetypeTerm.new(:code => 'at0002', :items => items)}
12
+ term_definitions = {'ja' => (term1.update term2), 'en' => term1}
13
+ items = {'text' => 'test', 'description' => 'test item'}
14
+ term4 = {'ac0003' => ArchetypeTerm.new(:code => 'ac0003', :items => items)}
15
+ constraint_definitions = {'ja' => term4}
15
16
  code_phrase = stub(CodePhrase, :code_string => '163020007')
16
17
  bind = {'at0000' => code_phrase}
17
- term_bindings = {'SNOMED-CT(2003)' => [bind]}
18
+ term_bindings = {'SNOMED-CT(2003)' => bind}
18
19
  @archetype_ontology =
19
20
  ArchetypeOntology.new(:primary_language => "ja",
20
21
  :languages_available => ['ja', 'en'],
22
+ :terminologies_available => ['SNOMED-CT(2003)'],
21
23
  :term_definitions => term_definitions,
22
24
  :constraint_definitions => constraint_definitions,
23
25
  :term_bindings => term_bindings,
@@ -40,8 +42,9 @@ describe ArchetypeOntology do
40
42
  @archetype_ontology.languages_available.should == ['ja', 'en']
41
43
  end
42
44
 
45
+
43
46
  it 'term_definition should be assigned properly' do
44
- @archetype_ontology.term_definition(:lang => 'ja', :code => 'at0000')[:text].should == 'Archetype Concept'
47
+ @archetype_ontology.term_definition(:lang => 'ja', :code => 'at0000').items['text'].should == 'Archetype Concept'
45
48
  end
46
49
 
47
50
  it 'term_codes should returnd all at codes' do
@@ -49,16 +52,16 @@ describe ArchetypeOntology do
49
52
  end
50
53
 
51
54
  it 'constraint_definitions should be assigned properly' do
52
- @archetype_ontology.constraint_definition(:lang => 'ja', :code => 'ac0000')[:text].
55
+ @archetype_ontology.constraint_definition(:lang => 'ja', :code => 'ac0003').items['text'].
53
56
  should == 'test'
54
57
  end
55
58
 
56
59
  it 'constrant_codes should return all ac codes' do
57
- @archetype_ontology.constraint_codes.should == ['ac0000']
60
+ @archetype_ontology.constraint_codes.should == ['ac0003']
58
61
  end
59
62
 
60
63
  it 'term_bindings should be assigned properly' do
61
- @archetype_ontology.term_bindings['SNOMED-CT(2003)'][0]['at0000'].
64
+ @archetype_ontology.term_bindings['SNOMED-CT(2003)']['at0000'].
62
65
  code_string.should == '163020007'
63
66
  end
64
67
 
@@ -85,5 +88,11 @@ describe ArchetypeOntology do
85
88
  it 'does not have MHLW code' do
86
89
  @archetype_ontology.should_not have_terminology 'MHLW'
87
90
  end
91
+
92
+ it 'term binding code_string is 163020007' do
93
+ @archetype_ontology.term_binding(:terminology => 'SNOMED-CT(2003)',
94
+ :code => 'at0000').code_string.
95
+ should == '163020007'
96
+ end
88
97
  end
89
98
 
@@ -1,5 +1,5 @@
1
1
  archetype (adl_version=1.4)
2
- adl-test-SOME_TYPE.generic_type_basic.draft
2
+ adl-test-SOME_TYPE.generic_type_basic.v1
3
3
 
4
4
  concept
5
5
  [at0000] -- root item
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-entry.archetype_language_order_of_translation_details.test
2
+ adl-test-entry.archetype_language_order_of_translation_details.v1
3
3
 
4
4
  concept
5
5
  [at0000] -- test
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-entry.archetype_internal_ref.test
2
+ adl-test-entry.archetype_internal_ref.v1
3
3
 
4
4
  concept
5
5
  [at0000]
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-entry.archetype_internal_ref.test
2
+ adl-test-entry.archetype_internal_ref.v1
3
3
 
4
4
  concept
5
5
  [at0000]
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-ENTRY.archetype_language.draft
2
+ adl-test-ENTRY.archetype_language.v1
3
3
 
4
4
  concept
5
5
  [at0000] -- test
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-ENTRY.archetype_language.draft
2
+ adl-test-ENTRY.archetype_language.v1
3
3
 
4
4
  concept
5
5
  [at0000] -- test
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-entry.archetype_language_order_of_translation_details.test
2
+ adl-test-entry.archetype_language_order_of_translation_details.v1
3
3
 
4
4
  concept
5
5
  [at0000] -- test
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-ENTRY.archetype_ontology.draft
2
+ adl-test-ENTRY.archetype_ontology.v1
3
3
  concept
4
4
  [at0000] -- empty definition test
5
5
  language
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-ENTRY.translation_author_language.draft
2
+ adl-test-ENTRY.translation_author_language.v1
3
3
 
4
4
  concept
5
5
  [at0000] -- test
@@ -1,5 +1,5 @@
1
1
  archetype
2
- adl-test-ENTRY.translation_language_author.draft
2
+ adl-test-ENTRY.translation_language_author.v1
3
3
 
4
4
  concept
5
5
  [at0000] -- test
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require File.dirname(__FILE__) + '/parser_spec_helper'
3
+ include OpenEHR::AM::Archetype
4
+ include OpenEHR::AM::Archetype::ConstraintModel
5
+
6
+ describe ADLParser do
7
+ context 'test with slash in comment after use node' do
8
+ before(:all) do
9
+ @archetype = adl14_archetype('adl-test-entry.archetype_internal_ref2.test.adl')
10
+ end
11
+
12
+ it 'is an instance of Archetype' do
13
+ @archetype.should be_an_instance_of Archetype
14
+ end
15
+
16
+ context 'attribute2' do
17
+ before(:all) do
18
+ @attribute2 = @archetype.definition.attributes[1].children[0]
19
+ end
20
+
21
+ it 'is ArchetypeInternalRef' do
22
+ @attribute2.should be_an_instance_of ArchetypeInternalRef
23
+ end
24
+
25
+ it 's occurrences upper 2' do
26
+ @attribute2.occurrences.upper.should be 2
27
+ end
28
+
29
+ it 's occurrences lower 1' do
30
+ @attribute2.occurrences.lower.should be 1
31
+ end
32
+
33
+ it 's path is /attribute2' do
34
+ @attribute2.path.should == '/attribute2'
35
+ end
36
+
37
+ it 's target_path is /attribute1' do
38
+ @attribute2.target_path.should == '/attribute1'
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,125 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require File.dirname(__FILE__) + '/parser_spec_helper'
3
+ include OpenEHR::Parser
4
+ include OpenEHR::AM::Archetype
5
+ include OpenEHR::AM::Archetype::ConstraintModel
6
+
7
+ describe ADLParser do
8
+ context 'ArchetypeInternalRef behavior test' do
9
+ before(:all) do
10
+ target_adl_file = 'adl-test-entry.archetype_internal_ref.test.adl'
11
+ ap = ADLParser.new(ADL14DIR + target_adl_file)
12
+ @archetype = ap.parse
13
+ end
14
+
15
+ it 'Archetype instance is generated' do
16
+ @archetype.should be_instance_of Archetype
17
+ end
18
+
19
+ context 'attribute 1 node' do
20
+ before(:all) do
21
+ @node = @archetype.definition.attributes[0]
22
+ end
23
+
24
+ it 's path is attribute 1' do
25
+ @node.path.should == '/attribute1'
26
+ end
27
+
28
+ it 's rm attribute name is SECTION' do
29
+ @node.rm_attribute_name.should == 'attribute1'
30
+ end
31
+
32
+ context 'children' do
33
+ before(:all) do
34
+ @child = @node.children[0]
35
+ end
36
+
37
+ it 's rm type name is SECTION' do
38
+ @child.rm_type_name.should == 'SECTION'
39
+ end
40
+ end
41
+ end
42
+
43
+ context 'attrubute 2 node' do
44
+ before(:all) do
45
+ @node = @archetype.definition.attributes[1]
46
+ end
47
+
48
+ it 's path is attribute 2' do
49
+ @node.path.should == '/attribute2'
50
+ end
51
+
52
+ context 'child' do
53
+ before(:all) do
54
+ @child = @node.children[0]
55
+ end
56
+
57
+ it 'is instance of ArchetypeInternalRef' do
58
+ @child.should be_an_instance_of ArchetypeInternalRef
59
+ end
60
+
61
+ it 's target path is /attribute1' do
62
+ @child.target_path.should == '/attribute1'
63
+ end
64
+
65
+ it 'path is /attribute2' do
66
+ @child.path.should == '/attribute2'
67
+ end
68
+
69
+ it 's occurrences upper is 2' do
70
+ @child.occurrences.upper.should be 2
71
+ end
72
+
73
+ it 's occurrences lower is 1' do
74
+ @child.occurrences.lower.should be 1
75
+ end
76
+ end
77
+
78
+ context 'attribute 3 node' do
79
+ before(:all) do
80
+ @node = @archetype.definition.attributes[2]
81
+ end
82
+
83
+ it 's path is /attribute3' do
84
+ @node.path.should == '/attribute3'
85
+ end
86
+
87
+ context 'child1' do
88
+ before(:all) do
89
+ @child1 = @node.children[0]
90
+ end
91
+
92
+ it 's path is /attribute3' do
93
+ @child1.path.should == '/attribute3'
94
+ end
95
+
96
+ it 's target path is /items[at0001]' do
97
+ @child1.target_path.should == '/items[at0001]'
98
+ end
99
+
100
+ it 's rm type name is COMPLEX_OBJECT' do
101
+ @child1.rm_type_name.should == 'COMPLEX_OBJECT'
102
+ end
103
+ end
104
+
105
+ context 'child2' do
106
+ before(:all) do
107
+ @child2 = @node.children[1]
108
+ end
109
+
110
+ it 's path is /attribute3' do
111
+ @child2.path.should == '/attribute3'
112
+ end
113
+
114
+ it 's target path is /items[at0002]' do
115
+ @child2.target_path.should == '/items[at0002]'
116
+ end
117
+
118
+ it 's rm_type_name is COMPLEX_OBJECT' do
119
+ @child2.rm_type_name.should == 'COMPLEX_OBJECT'
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,258 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require File.dirname(__FILE__) + '/parser_spec_helper'
3
+ include OpenEHR::AM::Archetype
4
+ include OpenEHR::AM::Archetype::ConstraintModel
5
+
6
+ describe ADLParser do
7
+ context 'ArchetypeInternalRef with generics' do
8
+ before(:all) do
9
+ @archetype = adl14_archetype('adl-test-SOME_TYPE.generic_type_use_node.draft.adl')
10
+ end
11
+
12
+ it 'is a instance of Archetype' do
13
+ @archetype.should be_an_instance_of Archetype
14
+ end
15
+
16
+ context 'interval_attr1 node' do
17
+ before(:all) do
18
+ @node = @archetype.definition.attributes[0].children[0]
19
+ end
20
+
21
+
22
+ it 's path is /iterval_attr[at0001]' do
23
+ @node.path.should == '/interval_attr[at0001]'
24
+ end
25
+
26
+ it 's rm type dis INTERVAL<QUANTITY>' do
27
+ @node.rm_type_name.should == 'INTERVAL<QUANTITY>'
28
+ end
29
+
30
+ context 'attributes' do
31
+ before(:all) do
32
+ @attributes = @node.attributes
33
+ end
34
+
35
+ context 'lower attribute' do
36
+ before(:all) do
37
+ @attribute = @attributes[0]
38
+ end
39
+
40
+ it 'path is /interval_attr[at0001]/lower' do
41
+ @attribute.path.should == '/interval_attr[at0001]/lower'
42
+ end
43
+
44
+ context 'lower node' do
45
+ before(:all) do
46
+ @lower = @attribute.children[0]
47
+ end
48
+
49
+ it 'rm type name is QUANTITY' do
50
+ @lower.rm_type_name.should == 'QUANTITY'
51
+ end
52
+
53
+ context 'lower attributes' do
54
+ before(:all) do
55
+ @lower_attributes = @lower.attributes
56
+ end
57
+
58
+ context 'property' do
59
+ before(:all) do
60
+ @property = @lower_attributes[0]
61
+ end
62
+
63
+ it 's path is /interval_attr[at0001]/lower/property' do
64
+ @property.path.should == '/interval_attr[at0001]/lower/property'
65
+ end
66
+
67
+ it 's rm attribute name is property' do
68
+ @property.rm_attribute_name.should == 'property'
69
+ end
70
+
71
+ it 'is temprature' do
72
+ @property.children[0].list.should == ['temperature']
73
+ end
74
+ end
75
+
76
+ context 'unit' do
77
+ before(:all) do
78
+ @unit = @lower_attributes[1]
79
+ end
80
+
81
+ it 's rm_attribute_name is unit' do
82
+ @unit.rm_attribute_name.should == 'unit'
83
+ end
84
+
85
+ it 'matches C' do
86
+ @unit.children[0].list.should == ['C']
87
+ end
88
+ end
89
+
90
+ context 'magnitude' do
91
+ before(:all) do
92
+ @magnitude = @lower_attributes[2]
93
+ end
94
+
95
+ it 's rm_attribute_name is magnitude' do
96
+ @magnitude.rm_attribute_name.should == 'magnitude'
97
+ end
98
+
99
+ it 's lower is 37.0' do
100
+ @magnitude.children[0].lower.should == 37.0
101
+ end
102
+
103
+ it 'is lower included' do
104
+ @magnitude.children[0].should be_lower_included
105
+ end
106
+
107
+ it 'is upper unbounded' do
108
+ @magnitude.children[0].should be_upper_unbounded
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+ context 'upper attributes' do
116
+ before(:all) do
117
+ @attribute = @attributes[1]
118
+ end
119
+
120
+ it 'path is /interval_attr[at0001]/lower' do
121
+ @attribute.path.should == '/interval_attr[at0001]/upper'
122
+ end
123
+
124
+ context 'upper node' do
125
+ before(:all) do
126
+ @upper = @attribute.children[0]
127
+ end
128
+
129
+ it 'rm type name is QUANTITY' do
130
+ @upper.rm_type_name.should == 'QUANTITY'
131
+ end
132
+
133
+ context 'upper attributes' do
134
+ before(:all) do
135
+ @upper_attributes = @upper.attributes
136
+ end
137
+
138
+ context 'property' do
139
+ before(:all) do
140
+ @property = @upper.attributes[0]
141
+ end
142
+
143
+ it 's path is /interval_attr[at0001]/upper/property' do
144
+ @property.path.should == '/interval_attr[at0001]/upper/property'
145
+ end
146
+
147
+ it 's rm attribute name is property' do
148
+ @property.rm_attribute_name.should == 'property'
149
+ end
150
+
151
+ it 'matches [temperature]' do
152
+ @property.children[0].list.should == ['temperature']
153
+ end
154
+ end
155
+
156
+ context 'unit' do
157
+ before(:all) do
158
+ @unit = @upper_attributes[1]
159
+ end
160
+
161
+ it 's rm_attribute_name is unit' do
162
+ @unit.rm_attribute_name.should == 'unit'
163
+ end
164
+
165
+ it 's matches C' do
166
+ @unit.children[0].list.should == ['C']
167
+ end
168
+ end
169
+
170
+ context 'magnitude' do
171
+ before(:all) do
172
+ @magnitude = @upper_attributes[2]
173
+ end
174
+
175
+ it 's rm_attribute_name is magnitude' do
176
+ @magnitude.rm_attribute_name.should == 'magnitude'
177
+ end
178
+
179
+ it 's magnitude lower is 39.0' do
180
+ @magnitude.children[0].lower.should == 39.0
181
+ end
182
+
183
+ it 's magnitude lower included' do
184
+ @magnitude.children[0].should be_lower_included
185
+ end
186
+
187
+ it 's upper unbounded' do
188
+ @magnitude.children[0].should be_upper_unbounded
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+ context 'lower_included attribute' do
195
+ before(:all) do
196
+ @attribute = @attributes[2]
197
+ end
198
+
199
+ it 's path is /interval_attr[at0001]/lower_included' do
200
+ @attribute.path.should == '/interval_attr[at0001]/lower_included'
201
+ end
202
+
203
+ context 'lower_included node' do
204
+ before(:all) do
205
+ @lower_included = @attribute.children[0]
206
+ end
207
+
208
+ it 'matches true valid' do
209
+ @lower_included.should be_true_valid
210
+ end
211
+ end
212
+ end
213
+
214
+ context 'upper_included attribute' do
215
+ before(:all) do
216
+ @attribute = @attributes[3]
217
+ end
218
+
219
+ it 's path is /interval_attr[at0001]/upper_included' do
220
+ @attribute.path.should == '/interval_attr[at0001]/upper_included'
221
+ end
222
+
223
+ context 'upper_include node' do
224
+ before(:all) do
225
+ @upper_included = @attribute.children[0]
226
+ end
227
+
228
+ it 'matches true valid' do
229
+ @upper_included.should be_true_valid
230
+ end
231
+ end
232
+ end
233
+ end
234
+ end
235
+
236
+ context 'interval_attr2 node' do
237
+ before(:all) do
238
+ @node = @archetype.definition.attributes[1].children[0]
239
+ end
240
+
241
+ it 'is an instance of ArchetypeInternalRef' do
242
+ @node.should be_an_instance_of ArchetypeInternalRef
243
+ end
244
+
245
+ it 's rm type name is INTERVAL<QUANTITY>' do
246
+ @node.rm_type_name.should == 'INTERVAL<QUANTITY>'
247
+ end
248
+
249
+ it 's target path is /interval_attr[at0001]' do
250
+ @node.target_path.should == '/interval_attr[at0001]'
251
+ end
252
+
253
+ it 's path is /interval_attr2' do
254
+ @node.path.should == '/interval_attr2'
255
+ end
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,98 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require File.dirname(__FILE__) + '/parser_spec_helper'
3
+ include OpenEHR::AM::Archetype::Ontology
4
+
5
+ describe ADLParser do
6
+ context 'ArchetypeOntology' do
7
+ before(:all) do
8
+ at = adl14_archetype('adl-test-entry.archetype_bindings.test.adl')
9
+ @ontology = at.ontology
10
+ end
11
+
12
+ it 'is an instance of ArchetypeOntology' do
13
+ @ontology.should be_an_instance_of ArchetypeOntology
14
+ end
15
+
16
+ it 's terminolgies available are SNOMED-CT' do
17
+ @ontology.terminologies_available.should == ['SNOMED-CT']
18
+ end
19
+ it 'has SNOMED-CT coding' do
20
+ @ontology.should have_terminology 'SNOMED-CT'
21
+ end
22
+
23
+ context 'term definitions, language en, code at0000' do
24
+ before(:all) do
25
+ @term_def = @ontology.term_definition(:lang => 'en',
26
+ :code => 'at0000')
27
+ end
28
+
29
+ it 's code is at0000' do
30
+ @term_def.code.should == 'at0000'
31
+ end
32
+
33
+ it 's item text is test' do
34
+ @term_def.items['text'].should == 'test'
35
+ end
36
+
37
+ it 's item description is test' do
38
+ @term_def.items['description'].should == 'test'
39
+ end
40
+ end
41
+
42
+ context 'constraint definitions' do
43
+ before(:all) do
44
+ @const_def = @ontology.constraint_definition(:lang => 'en',
45
+ :code => 'ac0001')
46
+ end
47
+
48
+ it 's code is at0001' do
49
+ @const_def.code.should == 'ac0001'
50
+ end
51
+
52
+ it 's items text is test constraint' do
53
+ @const_def.items['text'].should == 'test constraint'
54
+ end
55
+
56
+ it 's items description is *' do
57
+ @const_def.items['description'].should == '*'
58
+ end
59
+ end
60
+
61
+ context 'term_bindings' do
62
+ before(:all) do
63
+ @term_bindings = @ontology.term_bindings
64
+ end
65
+
66
+ it 'key is SNOMED-CT' do
67
+ @term_bindings.keys.should == ['SNOMED-CT']
68
+ end
69
+
70
+ it 's code is at0002' do
71
+ @term_bindings['SNOMED-CT'].keys.should == ['at0002']
72
+ end
73
+
74
+ context 'SNOMED-CT terminology, code is at0002' do
75
+ before(:all) do
76
+ @term = @ontology.
77
+ term_binding(:terminology => 'SNOMED-CT', :code => 'at0002')
78
+ end
79
+
80
+ it 'terminology id is SNOMED-CT' do
81
+ @term.terminology_id.value.should == 'SNOMED-CT'
82
+ end
83
+
84
+ it 'code_string is 123456' do
85
+ @term.code_string.should == '123456'
86
+ end
87
+ end
88
+ end
89
+
90
+ context 'constraint bindings' do
91
+ it 'terminology SNOMED-CT, constraint code is ac0001' do
92
+ @ontology.constraint_binding(:terminology => 'SNOMED-CT',
93
+ :code => 'ac0001').should ==
94
+ 'http://openEHR.org/testconstraintbinding'
95
+ end
96
+ end
97
+ end
98
+ end