[403] | 1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
| 2 | include OpenEHR::AM::Archetype::Ontology
|
---|
[411] | 3 | include OpenEHR::RM::DataTypes::Text
|
---|
[403] | 4 |
|
---|
| 5 | describe ArchetypeOntology do
|
---|
| 6 | before(:each) do
|
---|
[411] | 7 | items = {'TEXT' => 'text', 'DESC' => 'description'}
|
---|
| 8 | term1 = ArchetypeTerm.new(:code => 'at0000', :items => items)
|
---|
| 9 | items = {'TEXT' => 'concept'}
|
---|
| 10 | term2 = ArchetypeTerm.new(:code => 'at0001', :items => items)
|
---|
| 11 | term_definitions = {'ja' => [term1, term2]}
|
---|
| 12 | items = {'text' => 'test', 'description' => 'test item'}
|
---|
| 13 | term3 = ArchetypeTerm.new(:code => 'ac0000', :items => items)
|
---|
| 14 | constraint_definitions = {'ja' => [term3]}
|
---|
| 15 | code_phrase = stub(CodePhrase, :code_string => '163020007')
|
---|
| 16 | bind = {'at0000' => code_phrase}
|
---|
| 17 | term_bindings = {'SNOMED-CT(2003)' => [bind]}
|
---|
[403] | 18 | @archetype_ontology =
|
---|
[411] | 19 | ArchetypeOntology.new(:term_definitions => term_definitions,
|
---|
| 20 | :constraint_definitions => constraint_definitions,
|
---|
| 21 | :term_bindings => term_bindings,
|
---|
| 22 | :specialisation_depth => 0)
|
---|
[403] | 23 | end
|
---|
| 24 |
|
---|
| 25 | it 'should be an instance of ArchetypeOntology' do
|
---|
| 26 | @archetype_ontology.should be_an_instance_of ArchetypeOntology
|
---|
| 27 | end
|
---|
| 28 |
|
---|
[411] | 29 | it 'specialisation depth should be assigned properly' do
|
---|
| 30 | @archetype_ontology.specialisation_depth.should be_equal 0
|
---|
[403] | 31 | end
|
---|
| 32 |
|
---|
[411] | 33 | it 'term_definitions should be assigned properly' do
|
---|
| 34 | @archetype_ontology.term_definitions['ja'][0].code.should == 'at0000'
|
---|
[403] | 35 | end
|
---|
| 36 |
|
---|
[411] | 37 | it 'term_codes should returnd all at codes' do
|
---|
| 38 | @archetype_ontology.term_codes.should == ['at0000','at0001']
|
---|
[403] | 39 | end
|
---|
| 40 |
|
---|
[411] | 41 | it 'constraint_definitions should be assigned properly' do
|
---|
| 42 | @archetype_ontology.constraint_definitions['ja'][0].items['text'].
|
---|
| 43 | should == 'test'
|
---|
[403] | 44 | end
|
---|
| 45 |
|
---|
[411] | 46 | it 'constrant_codes should return all ac codes' do
|
---|
| 47 | @archetype_ontology.constraint_codes.should == ['ac0000']
|
---|
[403] | 48 | end
|
---|
| 49 |
|
---|
[411] | 50 | it 'term_bindings should be assigned properly' do
|
---|
| 51 | @archetype_ontology.term_bindings['SNOMED-CT(2003)'][0]['at0000'].
|
---|
| 52 | code_string.should == '163020007'
|
---|
[403] | 53 | end
|
---|
| 54 | end
|
---|
| 55 |
|
---|