open_ehr 0.9.5 → 1.0.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.
- data/History.txt +3 -0
- data/README.rdoc +35 -25
- data/VERSION +1 -1
- data/lib/open_ehr.rb +2 -3
- data/lib/open_ehr/am.rb +1 -2
- data/lib/open_ehr/am/openehr_profile.rb +0 -1
- data/lib/open_ehr/am/openehr_profile/data_types.rb +2 -1
- data/lib/open_ehr/am/openehr_profile/data_types/basic.rb +88 -1
- data/lib/open_ehr/am/openehr_profile/data_types/quantity.rb +51 -2
- data/lib/open_ehr/am/openehr_profile/data_types/text.rb +2 -2
- data/lib/open_ehr/assumed_library_types.rb +5 -0
- data/lib/open_ehr/parser/adl.rb +5 -5
- data/lib/open_ehr/parser/adl_grammar.tt +13 -16
- data/lib/open_ehr/parser/adl_parser.rb +13 -5
- data/lib/open_ehr/parser/cadl_grammar.tt +247 -31
- data/lib/open_ehr/parser/cadl_node.rb +25 -0
- data/lib/open_ehr/parser/dadl_grammar.tt +6 -6
- data/lib/open_ehr/parser/shared_token_grammar.tt +14 -5
- data/lib/open_ehr/rm.rb +1 -2
- data/lib/open_ehr/rm/composition/content/entry.rb +8 -1
- data/lib/open_ehr/rm/data_types.rb +2 -2
- data/lib/open_ehr/rm/data_types/quantity.rb +1 -2
- data/lib/open_ehr/rm/data_types/quantity/date_time.rb +8 -5
- data/lib/open_ehr/rm/data_types/text.rb +7 -6
- data/lib/open_ehr/rm/support/identification.rb +13 -9
- data/open_ehr.gemspec +34 -4
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/c_dv_state_spec.rb +34 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/non_terminal_state_spec.rb +36 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_machine_spec.rb +34 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_spec.rb +26 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/terminal_state_spec.rb +18 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/transition_spec.rb +62 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_ordinal_spec.rb +41 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_quantity_spec.rb +50 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_quantity_item_spec.rb +46 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb +0 -1
- data/spec/lib/open_ehr/assumed_library_types/interval_spec.rb +5 -0
- data/spec/lib/open_ehr/parser/adl14/adl-test-composition.dv_coded_text.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_desc_missing_purpose.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_ordinal.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_empty.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full2.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full3.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_item_units_only.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_list.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_property.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_reversed.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_binding.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_ref.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.empty_other_contributors.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.missing_language.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.mixed_node_types.draft.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.most_minimal.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.multi_language.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.special_string.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test1.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test2.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding2.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_BOM_support.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_support.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl_archetype_ontology_binding_spec.rb +3 -3
- data/spec/lib/open_ehr/parser/c_dv_quantity_any_allowed_spec.rb +34 -0
- data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_for_lacked_items_spec.rb +36 -0
- data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_spec.rb +146 -0
- data/spec/lib/open_ehr/parser/cdv_ordinal_parse_spec.rb +231 -0
- data/spec/lib/open_ehr/parser/code_phrase_spec.rb +7 -2
- data/spec/lib/open_ehr/parser/constraint_binding_spec.rb +26 -0
- data/spec/lib/open_ehr/parser/constraint_ref_spec.rb +32 -0
- data/spec/lib/open_ehr/parser/dv_coded_text_parse_spec.rb +27 -0
- data/spec/lib/open_ehr/parser/empty_other_contributors_spec.rb +19 -0
- data/spec/lib/open_ehr/parser/missing_language_spec.rb +20 -0
- data/spec/lib/open_ehr/parser/missing_purpose_spec.rb +23 -0
- data/spec/lib/open_ehr/parser/mixed_node_types_spec.rb +16 -0
- data/spec/lib/open_ehr/parser/most_minimal_adl_spec.rb +19 -0
- data/spec/lib/open_ehr/parser/multi_language_spec.rb +58 -0
- data/spec/lib/open_ehr/parser/path_based_terminology_binding_spec.rb +30 -0
- data/spec/lib/open_ehr/parser/special_string_spec.rb +20 -0
- data/spec/lib/open_ehr/parser/structure_comment_spec.rb +21 -0
- data/spec/lib/open_ehr/parser/structure_nested_comments_spec.rb +22 -0
- data/spec/lib/open_ehr/parser/structure_spec.rb +202 -0
- data/spec/lib/open_ehr/parser/term_binding_spec.rb +54 -0
- data/spec/lib/open_ehr/parser/unicode_bom_spec.rb +17 -0
- data/spec/lib/open_ehr/parser/unicode_support_spec.rb +46 -0
- data/spec/lib/open_ehr/rm/common/change_control/imported_version_spec.rb +0 -1
- data/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb +2 -2
- data/spec/lib/open_ehr/rm/common/change_control/version_spec.rb +0 -1
- data/spec/lib/open_ehr/rm/common/change_control/versioned_object_spec.rb +0 -1
- data/spec/lib/open_ehr/rm/common/generic/revision_history_item_spec.rb +3 -3
- data/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb +12 -2
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +1 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/{dv_tempral_spec.rb → dv_temporal_spec.rb} +1 -0
- data/spec/lib/open_ehr/rm/data_types/text/dv_text_spec.rb +25 -3
- data/spec/lib/open_ehr/rm/demographic/party_spec.rb +1 -3
- data/spec/lib/open_ehr/rm/support/identification/access_group_ref_spec.rb +2 -2
- data/spec/lib/open_ehr/rm/support/identification/object_version_id_spec.rb +3 -4
- metadata +69 -39
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# ticket #176
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Constraint Refs' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@archetype = adl14_archetype('adl-test-entry.constraint_ref.test.adl')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'archetype is an instance of OpenEHR::AM::Archetype::Archetype' do
|
|
12
|
+
@archetype.should be_an_instance_of OpenEHR::AM::Archetype::Archetype
|
|
13
|
+
end
|
|
14
|
+
context 'constraint ref node' do
|
|
15
|
+
before(:all) do
|
|
16
|
+
@cr = @archetype.definition.attributes[0].children[0].attributes[0].
|
|
17
|
+
children[0].attributes[0].children[0].attributes[0].children[0]
|
|
18
|
+
end
|
|
19
|
+
it 'is an instance of ConstrantRef' do
|
|
20
|
+
@cr.should be_an_instance_of OpenEHR::AM::Archetype::ConstraintModel::ConstraintRef
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'path is /content[at0001]/items[at0002]/value/defining_code' do
|
|
24
|
+
@cr.path.should == '/content[at0001]/items[at0002]/value/defining_code'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'reference is ac0001' do
|
|
28
|
+
@cr.reference.should == 'ac0001'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
3
|
+
include ::OpenEHR::RM::DataTypes::Text
|
|
4
|
+
require 'open_ehr/am/openehr_profile/data_types/text'
|
|
5
|
+
include ::OpenEHR::AM::OpenEHRProfile::DataTypes::Text
|
|
6
|
+
|
|
7
|
+
describe ADLParser do
|
|
8
|
+
describe DvCodedText do
|
|
9
|
+
before(:all) do
|
|
10
|
+
archetype = adl14_archetype('adl-test-composition.dv_coded_text.test.adl')
|
|
11
|
+
@c_code_phrase = archetype.definition.attributes[0].children[0].
|
|
12
|
+
attributes[0].children[0]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'is an instance of CCodePhrase' do
|
|
16
|
+
@c_code_phrase.should be_an_instance_of CCodePhrase
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'terminology is openehr' do
|
|
20
|
+
@c_code_phrase.terminology_id.value.should == 'openehr'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'code list is 431' do
|
|
24
|
+
@c_code_phrase.code_list.should == ['431']
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# ticket 179
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Empty Other Contributors' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@archetype = adl14_archetype('adl-test-entry.empty_other_contributors.test.adl')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'archetype should be an instance of OpenEHR::AM::Archetype::Archetype' do
|
|
12
|
+
@archetype.should be_an_instance_of OpenEHR::AM::Archetype::Archetype
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'other contributer should be nil' do
|
|
16
|
+
@archetype.description.other_contributors.should be_nil
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# ticket 180
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Missing language' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@archetype = adl14_archetype('adl-test-entry.missing_language.test.adl')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'is an instance of Archetype' do
|
|
12
|
+
@archetype.should be_an_instance_of OpenEHR::AM::Archetype::Archetype
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'original language is alternated from primary language of ontology section' do
|
|
16
|
+
@archetype.original_language.code_string.should == 'zh'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ticket 181
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Missing purpose' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@archetype = adl14_archetype('adl-test-entry.archetype_desc_missing_purpose.test.adl')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'is an instance of Archetype' do
|
|
12
|
+
@archetype.should be_an_instance_of OpenEHR::AM::Archetype::Archetype
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# If porpose in description section was nil, __unknown__ is altered
|
|
16
|
+
# for backward compatibility
|
|
17
|
+
|
|
18
|
+
it 'purpose is __unknown__' do
|
|
19
|
+
@archetype.description.details['en'].purpose.should == '__unknown__'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# ticket 182
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Mixed node types' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@archetype = adl14_archetype('adl-test-entry.mixed_node_types.draft.adl')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'is an instance of Archetype' do
|
|
12
|
+
@archetype.should be_an_instance_of OpenEHR::AM::Archetype::Archetype
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# ticket 183
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Most minimal ADL' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@archetype = adl14_archetype('adl-test-entry.most_minimal.test.adl')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'is an instance of Archetype' do
|
|
12
|
+
@archetype.should be_an_instance_of OpenEHR::AM::Archetype::Archetype
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'original language is en' do
|
|
16
|
+
@archetype.original_language.code_string.should == 'en'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
3
|
+
include ::OpenEHR::RM::DataTypes::Text
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context do
|
|
7
|
+
before(:all) do
|
|
8
|
+
archetype = adl14_archetype('adl-test-entry.multi_language.test.adl')
|
|
9
|
+
@ontology = archetype.ontology
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'primary language is en' do
|
|
13
|
+
@ontology.primary_language.should == 'en'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'languages available are sv and en' do
|
|
17
|
+
@ontology.languages_available.should == ['en', 'sv']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'term definition' do
|
|
21
|
+
before(:all) do
|
|
22
|
+
@term_def = @ontology.term_definitions
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'languages defined are sv and en' do
|
|
26
|
+
@term_def.keys.should == ['en','sv']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context 'en items' do
|
|
30
|
+
before(:all) do
|
|
31
|
+
@en = @term_def['en']['at0000'].items
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'text is most minimal' do
|
|
35
|
+
@en['text'].should == 'most minimal'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'description is most minimal' do
|
|
39
|
+
@en['description'].should == 'most minimal'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context 'sv items' do
|
|
44
|
+
before(:all) do
|
|
45
|
+
@en = @term_def['sv']['at0000'].items
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'text is most minimal' do
|
|
49
|
+
@en['text'].should == 'mesta minimal'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'description is most minimal' do
|
|
53
|
+
@en['description'].should == 'mesta minimal'
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ticket 188
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'term bindings spec' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
archetype = adl14_archetype('adl-test-entry.term_binding2.test.adl')
|
|
9
|
+
@item = archetype.ontology.term_bindings['LNC205']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'key is path' do
|
|
13
|
+
@item.should have_key '/data[at0002]/events[at0003]/data[at0001]/item[at0004]'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context 'term' do
|
|
17
|
+
before(:all) do
|
|
18
|
+
@term = @item['/data[at0002]/events[at0003]/data[at0001]/item[at0004]'][0]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'terminology id is LNC205' do
|
|
22
|
+
@term.terminology_id.name.should == 'LNC205'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'code is 8310-5' do
|
|
26
|
+
@term.code_string.should == '8310-5'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# ticket 186
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Special string' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
archetype = adl14_archetype('adl-test-entry.special_string.test.adl')
|
|
9
|
+
@attr = archetype.definition.attributes[0].children[0].attributes
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it '1st node string is some\"thing' do
|
|
13
|
+
@attr[0].children[0].list[0].should == 'some\"thing'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it '2nd node string is any\\thing' do
|
|
17
|
+
@attr[1].children[0].list[0].should == "any\\thing"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ticket 187
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Structure spec' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
archetype = adl14_archetype('adl-test-entry.structure_test2.test.adl')
|
|
9
|
+
@definition = archetype.definition
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'rm type name is ENTRY' do
|
|
13
|
+
@definition.rm_type_name.should == 'ENTRY'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it '1st attribute type name is items' do
|
|
17
|
+
@definition.attributes[0].rm_attribute_name.should ==
|
|
18
|
+
'subject_relationship'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# ticket 187
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Structure spec' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
archetype = adl14_archetype('openEHR-EHR-CLUSTER.auscultation.v1.adl')
|
|
9
|
+
@definition = archetype.definition
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'rm type name is CLUSTER' do
|
|
13
|
+
@definition.rm_type_name.should == 'CLUSTER'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it '1st attribute type name is items' do
|
|
17
|
+
@definition.attributes[0].rm_attribute_name.should ==
|
|
18
|
+
'items'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# ticket 187
|
|
2
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
|
+
require File.dirname(__FILE__) + '/parser_spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ADLParser do
|
|
6
|
+
context 'Structure spec' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
archetype = adl14_archetype('adl-test-entry.structure_test1.test.adl')
|
|
9
|
+
@definition = archetype.definition
|
|
10
|
+
@occurrences = OpenEHR::AssumedLibraryTypes::Interval.new(
|
|
11
|
+
:upper => 1, :lower => 1)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'root definition object' do
|
|
15
|
+
it 'rm_type_name is ENTRY' do
|
|
16
|
+
@definition.rm_type_name.should == 'ENTRY'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'path is /' do
|
|
20
|
+
@definition.path.should == '/'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'node_id is at0000' do
|
|
24
|
+
@definition.node_id.should == 'at0000'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'occurrences is default 1,1' do
|
|
28
|
+
@definition.occurrences.should == @occurrences
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'attributes size is 2' do
|
|
32
|
+
@definition.attributes.size.should be 2
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context 'first attribute' do
|
|
37
|
+
before(:all) do
|
|
38
|
+
@attr = @definition.attributes[0]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'rm_attribute_name is subject_relationship' do
|
|
42
|
+
@attr.rm_attribute_name.should == 'subject_relationship'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'has 1 child' do
|
|
46
|
+
@attr.children.size.should be 1
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context '2nd level object' do
|
|
50
|
+
before(:all) do
|
|
51
|
+
@obj = @attr.children[0]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'rm type name is RELATED_PARTY' do
|
|
55
|
+
@obj.rm_type_name.should == 'RELATED_PARTY'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'node id shold be nil' do
|
|
59
|
+
@obj.node_id.should be_nil
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'occurrences is default' do
|
|
63
|
+
@obj.occurrences.should == @occurrences
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'attributes size is 1' do
|
|
67
|
+
@obj.attributes.size.should be 1
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'attribute of 2nd level object' do
|
|
71
|
+
before(:all) do
|
|
72
|
+
@attr = @obj.attributes[0]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'rm attribute name is relationship' do
|
|
76
|
+
@attr.rm_attribute_name.should == 'relationship'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'children size is 1' do
|
|
80
|
+
@attr.children.size.should be 1
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
context 'leaf object' do
|
|
84
|
+
before(:all) do
|
|
85
|
+
@leaf = @attr.children[0]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'rm type name is TEXT' do
|
|
89
|
+
@leaf.rm_type_name.should == 'TEXT'
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'occurences is default' do
|
|
93
|
+
@leaf.occurrences.should == @occurrences
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'node id should be nil' do
|
|
97
|
+
@leaf.node_id.should be_nil
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'attributes size is 1' do
|
|
101
|
+
@leaf.attributes.size.should be 1
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context 'attribute of leaf object' do
|
|
105
|
+
before(:all) do
|
|
106
|
+
@attr = @leaf.attributes[0]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'rm attribute name is value' do
|
|
110
|
+
@attr.rm_attribute_name.should == 'value'
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'children size is 1' do
|
|
114
|
+
@attr.children.size.should be 1
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
context 'primitive constraint of leaf object' do
|
|
118
|
+
before(:all) do
|
|
119
|
+
@cstring = @attr.children[0]
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it 'string constraint pattern is nil' do
|
|
123
|
+
@cstring.pattern.should be_nil
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'list constraint is self' do
|
|
127
|
+
@cstring.list.should == ['self']
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'list size is 1' do
|
|
131
|
+
@cstring.list.size.should be 1
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'second attribute of root' do
|
|
141
|
+
before(:all) do
|
|
142
|
+
@attr = @definition.attributes[1]
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'rm attribute name is members' do
|
|
146
|
+
@attr.rm_attribute_name.should == 'members'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'existence are 0..1' do
|
|
150
|
+
existence = OpenEHR::AssumedLibraryTypes::Interval.new(
|
|
151
|
+
:lower => 0, :upper => 1)
|
|
152
|
+
@attr.existence.should == existence
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'cardinality interval is 0..8' do
|
|
156
|
+
interval = OpenEHR::AssumedLibraryTypes::Interval.new(
|
|
157
|
+
:lower => 0, :upper => 8)
|
|
158
|
+
@attr.cardinality.interval.should == interval
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'children size are 2' do
|
|
162
|
+
@attr.children.size.should be 2
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
context '1st person' do
|
|
166
|
+
before(:all) do
|
|
167
|
+
@first = @attr.children[0]
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'rm type name is PERSON' do
|
|
171
|
+
@first.rm_type_name.should == 'PERSON'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'occurrences are default' do
|
|
175
|
+
@first.occurrences.should == @occurrences
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it 'attributes size is 1' do
|
|
179
|
+
@first.attributes.size.should be 1
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
context '2nd person' do
|
|
184
|
+
before(:all) do
|
|
185
|
+
@second = @attr.children[1]
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it 'rm type name is PERSON' do
|
|
189
|
+
@second.rm_type_name.should == 'PERSON'
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it 'occurences is upper unbounded' do
|
|
193
|
+
occurrences = OpenEHR::AssumedLibraryTypes::Interval.new(
|
|
194
|
+
:lower => 0)
|
|
195
|
+
@second.occurrences.should == occurrences
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|