open_ehr 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/History.txt +3 -0
  2. data/README.rdoc +3 -3
  3. data/VERSION +1 -1
  4. data/lib/open_ehr/am/archetype/constraint_model/primitive.rb +61 -34
  5. data/lib/open_ehr/am/openehr_profile/data_types/basic.rb +27 -0
  6. data/lib/open_ehr/am/openehr_profile/data_types/quantity.rb +18 -0
  7. data/lib/open_ehr/am/openehr_profile/data_types/text.rb +22 -0
  8. data/lib/open_ehr/am/openehr_profile/data_types.rb +12 -0
  9. data/lib/open_ehr/am/openehr_profile.rb +10 -0
  10. data/lib/open_ehr/am.rb +2 -0
  11. data/lib/open_ehr/assumed_library_types.rb +30 -25
  12. data/lib/open_ehr/parser/cadl_grammar.tt +479 -163
  13. data/lib/open_ehr/parser/shared_token_grammar.tt +63 -43
  14. data/lib/open_ehr/rm/data_types/quantity/date_time.rb +27 -14
  15. data/lib/open_ehr.rb +1 -1
  16. data/open_ehr.gemspec +17 -6
  17. data/spec/lib/open_ehr/am/archetype/assertion/operator_kind_spec.rb +4 -0
  18. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_spec.rb +20 -48
  19. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_time_spec.rb +33 -8
  20. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_duration_spec.rb +19 -52
  21. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_string_spec.rb +2 -3
  22. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_time_spec.rb +27 -7
  23. data/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb +0 -1
  24. data/spec/lib/open_ehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb +35 -0
  25. data/spec/lib/open_ehr/parser/adl14/adl-test-SOME_TYPE.generic_type_basic.draft.adl +1 -1
  26. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_slot.test.adl +1 -1
  27. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_slot.test2.adl +1 -1
  28. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.basic_types.test.adl +3 -3
  29. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_code_phrase.test.adl +1 -1
  30. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.datetime.test.adl +1 -1
  31. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.durations.test.adl +2 -4
  32. data/spec/lib/open_ehr/parser/adl_archetype_internal_ref_with_generics_spec.rb +6 -6
  33. data/spec/lib/open_ehr/parser/adl_archetype_slot_cluster_spec.rb +101 -0
  34. data/spec/lib/open_ehr/parser/adl_archetype_slot_spec.rb +193 -0
  35. data/spec/lib/open_ehr/parser/adl_archetype_uncommon_term_keys_spec.rb +25 -0
  36. data/spec/lib/open_ehr/parser/adl_parser_spec.rb +6 -6
  37. data/spec/lib/open_ehr/parser/basic_generic_type_spec.rb +18 -0
  38. data/spec/lib/open_ehr/parser/basic_type_spec.rb +2922 -0
  39. data/spec/lib/open_ehr/parser/code_phrase_spec.rb +91 -0
  40. data/spec/lib/open_ehr/parser/date_time_spec.rb +1953 -0
  41. data/spec/lib/open_ehr/parser/duration_spec.rb +475 -0
  42. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_duration_spec.rb +44 -0
  43. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb +6 -2
  44. data/spec/spec_helper.rb +3 -2
  45. metadata +52 -41
  46. data/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb +0 -21
  47. data/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb +0 -29
  48. data/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb +0 -19
  49. data/lib/open_ehr/am/open_ehr_profile/data_types/text.rb +0 -15
@@ -0,0 +1,193 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require File.dirname(__FILE__) + '/parser_spec_helper'
3
+ include OpenEHR::AM::Archetype::ConstraintModel
4
+ include OpenEHR::AM::Archetype::ConstraintModel::Primitive
5
+ include OpenEHR::AM::Archetype::Assertion
6
+
7
+ # ticket 166
8
+
9
+ describe ADLParser do
10
+ context ArchetypeSlot do
11
+ before(:all) do
12
+ archetype = adl14_archetype('adl-test-entry.archetype_slot.test.adl')
13
+ @slot = archetype.definition.attributes[0].children[0]
14
+ end
15
+
16
+ it 'is an isntance of ArchetypeSlot' do
17
+ @slot.should be_an_instance_of ArchetypeSlot
18
+ end
19
+
20
+ it 's rm_type name is SECTION' do
21
+ @slot.rm_type_name.should == 'SECTION'
22
+ end
23
+
24
+ it 's node_id is at0000' do
25
+ @slot.node_id.should == 'at0001'
26
+ end
27
+
28
+ it 's occurrences upper is 1' do
29
+ @slot.occurrences.upper.should be 1
30
+ end
31
+
32
+ it 's occurrences lower is 0' do
33
+ @slot.occurrences.lower.should be 0
34
+ end
35
+
36
+ context 'include' do
37
+ before(:all) do
38
+ @includes = @slot.includes
39
+ end
40
+ it 's includes 1 constraint' do
41
+ @includes.size.should be 1
42
+ end
43
+
44
+ context 'assert expression node' do
45
+ before(:all) do
46
+ @item = @includes[0].expression
47
+ end
48
+
49
+ it 'item is an instance of ExprBinaryOperator' do
50
+ @item.should be_an_instance_of ExprBinaryOperator
51
+ end
52
+
53
+ it 'operator is OP_MATCHES' do
54
+ @item.operator.should == OperatorKind::OP_MATCHES
55
+ end
56
+
57
+ context 'left operand' do
58
+ before(:all) do
59
+ @left_operand = @item.left_operand
60
+ end
61
+
62
+ it 'is instance of ExprLeaf' do
63
+ @left_operand.should be_an_instance_of ExprLeaf
64
+ end
65
+
66
+ it 's item is domain_concept' do
67
+ @left_operand.item.should == 'domain_concept'
68
+ end
69
+ end
70
+
71
+ context 'right operand' do
72
+ before(:all) do
73
+ @right_operand = @item.right_operand
74
+ end
75
+
76
+ it 'is an instance of ExprLeaf' do
77
+ @right_operand.should be_an_instance_of ExprLeaf
78
+ end
79
+
80
+ it 's item type is CString' do
81
+ @right_operand.item.should be_an_instance_of CString
82
+ end
83
+
84
+ it 's item pattern is /blood_pressure.v1/' do
85
+ @right_operand.item.pattern.should == '/blood_pressure.v1/'
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ context 'excludes' do
92
+ before(:all) do
93
+ @excludes = @slot.excludes
94
+ end
95
+
96
+ it 's excludes 2 cnstraints' do
97
+ @excludes.size.should be 2
98
+ end
99
+
100
+ context '1st node' do
101
+ before(:all) do
102
+ @node = @excludes[0].expression
103
+ end
104
+
105
+ it 'is an instance of ExprBinaryOperator' do
106
+ @node.should be_an_instance_of ExprBinaryOperator
107
+ end
108
+
109
+ it 's operator is OP_MATCHES' do
110
+ @node.operator.should == OperatorKind::OP_MATCHES
111
+ end
112
+
113
+ context 'left operand' do
114
+ before(:all) do
115
+ @left_operand = @node.left_operand
116
+ end
117
+
118
+ it 'is an instance of ExprLeaf' do
119
+ @left_operand.should be_an_instance_of ExprLeaf
120
+ end
121
+
122
+ it 's item type is domain_concept' do
123
+ @left_operand.item.should == 'domain_concept'
124
+ end
125
+ end
126
+
127
+ context 'right operand' do
128
+ before(:all) do
129
+ @right_operand = @node.right_operand
130
+ end
131
+
132
+ it 'is an instance of ExprLeaf' do
133
+ @right_operand.should be_an_instance_of ExprLeaf
134
+ end
135
+
136
+ it 's item should be an instance of CString' do
137
+ @right_operand.item.should be_an_instance_of CString
138
+ end
139
+
140
+ it 's item pattern is /blood_pressure.v2/' do
141
+ @right_operand.item.pattern.should == '/blood_pressure.v2/'
142
+ end
143
+ end
144
+ end
145
+
146
+ context '2nd node' do
147
+ before(:all) do
148
+ @node = @excludes[1].expression
149
+ end
150
+
151
+ it 'is an instance of ExprBinaryOperator' do
152
+ @node.should be_an_instance_of ExprBinaryOperator
153
+ end
154
+
155
+ it 's operator is OP_MATCHES' do
156
+ @node.operator.should == OperatorKind::OP_MATCHES
157
+ end
158
+
159
+ context 'left operand' do
160
+ before(:all) do
161
+ @left_operand = @node.left_operand
162
+ end
163
+
164
+ it 'is an instance of ExprLeaf' do
165
+ @left_operand.should be_an_instance_of ExprLeaf
166
+ end
167
+
168
+ it 's item is domain_concept' do
169
+ @left_operand.item.should == 'domain_concept'
170
+ end
171
+ end
172
+
173
+ context 'right operand' do
174
+ before(:all) do
175
+ @right_operand = @node.right_operand
176
+ end
177
+
178
+ it 'is an instance of ExprLeaf' do
179
+ @right_operand.should be_an_instance_of ExprLeaf
180
+ end
181
+
182
+ it 's item type is CString' do
183
+ @right_operand.item.should be_an_instance_of CString
184
+ end
185
+
186
+ it 's item pattern is /.*/' do
187
+ @right_operand.item.pattern.should == '/.*/'
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require File.dirname(__FILE__) + '/parser_spec_helper'
3
+
4
+ # ticket 167
5
+
6
+ describe ADLParser do
7
+ context 'Archetype uncommon keys' do
8
+ before(:all) do
9
+ archetype = adl14_archetype('adl-test-entry.archetype_uncommonkeys.test.adl')
10
+ @aterm = archetype.ontology.term_definition(:lang => 'en', :code => 'at0000')
11
+ end
12
+
13
+ it 's anotherkey value is another key value' do
14
+ @aterm.items['anotherkey'].should == 'another key value'
15
+ end
16
+
17
+ it 's text value is test text' do
18
+ @aterm.items['text'].should == 'test text'
19
+ end
20
+
21
+ it 's description is test description' do
22
+ @aterm.items['description'].should == 'test description'
23
+ end
24
+ end
25
+ end
@@ -204,7 +204,7 @@ describe ADLParser do
204
204
  end
205
205
 
206
206
  it 'expression value of assertion0 is /clinical_synopsis\.v1/' do
207
- @assertion0.expression.item.pattern.should == '/clinical_synopsis\.v1/'
207
+ @assertion0.expression.right_operand.item.pattern.should == '/clinical_synopsis\.v1/'
208
208
  end
209
209
  end
210
210
 
@@ -222,7 +222,7 @@ describe ADLParser do
222
222
  end
223
223
 
224
224
  it 'expression value of assertion1 is /problem\.v1/' do
225
- @assertion1.expression.item.pattern.should ==
225
+ @assertion1.expression.right_operand.item.pattern.should ==
226
226
  '/problem\.v1/'
227
227
  end
228
228
  end
@@ -241,7 +241,7 @@ describe ADLParser do
241
241
  end
242
242
 
243
243
  it 'expression value of Assertion2 is /problem\.v1/' do
244
- @assertion2.expression.item.pattern.should ==
244
+ @assertion2.expression.right_operand.item.pattern.should ==
245
245
  '/problem-diagnosis\.v1/'
246
246
  end
247
247
  end
@@ -260,7 +260,7 @@ describe ADLParser do
260
260
  end
261
261
 
262
262
  it 'expression value of assertion3 is /problem\.v1/' do
263
- @assertion3.expression.item.pattern.should ==
263
+ @assertion3.expression.right_operand.item.pattern.should ==
264
264
  '/problem-diagnosis-histological\.v1/'
265
265
  end
266
266
  end
@@ -279,7 +279,7 @@ describe ADLParser do
279
279
  end
280
280
 
281
281
  it 'expression value of assertion4 is /problem\.v1/' do
282
- @assertion4.expression.item.pattern.should ==
282
+ @assertion4.expression.right_operand.item.pattern.should ==
283
283
  '/problem-genetic\.v1/'
284
284
  end
285
285
  end
@@ -298,7 +298,7 @@ describe ADLParser do
298
298
  end
299
299
 
300
300
  it 'expression value of assertion5 is /problem\.v1/' do
301
- @assertion5.expression.item.pattern.should ==
301
+ @assertion5.expression.right_operand.item.pattern.should ==
302
302
  '/risk\.v1/'
303
303
  end
304
304
  end
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require File.dirname(__FILE__) + '/parser_spec_helper'
3
+ include OpenEHR::AM::Archetype
4
+
5
+ # ticket 169
6
+ # almost same as adl_archetype_internal_ref_with_generics_spec.rb
7
+
8
+ describe ADLParser do
9
+ context 'Basic Generic type' do
10
+ before(:all) do
11
+ @archetype = adl14_archetype('adl-test-SOME_TYPE.generic_type_basic.draft.adl')
12
+ end
13
+
14
+ it 'is an instance of Archetype' do
15
+ @archetype.should be_an_instance_of Archetype
16
+ end
17
+ end
18
+ end