Changeset 264 for ruby


Ignore:
Timestamp:
Sep 14, 2009, 11:55:09 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

archetype id corrected

Location:
ruby/branches/0.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/rm/support/identification.rb

    r262 r264  
    5353         
    5454          def initialize(args = {})
    55             super(args)
    5655            if args[:value].nil?
    5756              self.rm_originator = args[:rm_originator]
     
    6261              self.specialisation = args[:specialisation]
    6362            else
    64               self.value = args[:value]
     63              super(args)
    6564            end
    6665          end
     
    8483
    8584          def domain_concept
    86             return @concept_name + '-' + @specialisation
     85            if @specialisation.nil?
     86              return @concept_name
     87            else
     88              return @concept_name + '-' + @specialisation
     89            end
    8790          end
    8891
     
    131134            @specialisation = specialisation
    132135          end
     136
    133137          def version_id=(version_id)
    134138            raise ArgumentError, "version_id not valid" if version_id.nil? or version_id.empty?
  • ruby/branches/0.5/spec/lib/open_ehr/rm/support/identification/archetype_id_spec.rb

    r262 r264  
    4242    @archetype_id.version_id.should == 'v2'
    4343  end
     44
     45  it 'should raise ArgumentError with wrong id format' do
     46    lambda {
     47      ArchetypeID.new(:value =>'wrong-format')
     48    }.should raise_error ArgumentError
     49  end
     50
     51  it 'should raise ArgumentError with nil concept name' do
     52    lambda {
     53      @archetype_id.concept_name = nil
     54    }.should raise_error ArgumentError
     55  end
     56
     57  it 'should raise ArgumentError with wrong domain concept format' do
     58    lambda {
     59      @archetype_id.domain_concept = '0123'
     60    }.should raise_error ArgumentError
     61  end
     62
     63  it 'should raise ArgumentError with empty rm_entity' do
     64    lambda {
     65      @archetype_id.rm_entity = ''
     66    }.should raise_error ArgumentError
     67  end
     68
     69  it 'should raise ArgumentError with nil rm_entity' do
     70    lambda {
     71      @archetype_id.rm_entity = nil
     72    }.should raise_error ArgumentError
     73  end
     74
     75  it 'should raise ArgumentError with empty rm_originator' do
     76    lambda {
     77      @archetype_id.rm_originator = ''
     78    }.should raise_error ArgumentError
     79  end
     80
     81  it 'should raise ArgumentError with nil rm_originator' do
     82    lambda {
     83      @archetype_id.rm_originator = nil
     84    }.should raise_error ArgumentError
     85  end
     86
     87  it 'should raise ArgumentError with empty specialisation' do
     88    lambda {
     89      @archetype_id.specialisation = ''
     90    }.should raise_error ArgumentError
     91  end
     92
     93  it 'should not raise ArgumentError with nil specialisation' do
     94    lambda {
     95      @archetype_id.specialisation = nil
     96    }.should_not raise_error ArgumentError
     97  end
     98
     99  describe 'another constructor' do
     100    before(:each) do
     101      @archetype_id = ArchetypeID.new(:rm_originator => 'openEHR',
     102                                      :rm_name => 'EHR',
     103                                      :rm_entity => 'EVALUATION',
     104                                      :concept_name => 'clinical_synopsis',
     105                                      :version_id => 'v1')
     106    end
     107
     108    it 'should be an instance of ArchetypeID' do
     109      @archetype_id.should be_an_instance_of ArchetypeID
     110    end
     111
     112    it 'domain_concept should be clinical_synopsis' do
     113      @archetype_id.domain_concept.should == 'clinical_synopsis'
     114    end
     115  end
     116
     117  describe 'domain concept' do
     118    before(:each) do
     119      @archetype_id.domain_concept = 'progress_note-naturopathy'
     120    end
     121
     122    it 'concept_name should be progress note' do
     123      @archetype_id.concept_name.should == 'progress_note'
     124    end
     125
     126    it 'specialisation should be naturopathy' do
     127      @archetype_id.specialisation === 'naturopathy'
     128    end
     129
     130    it 'should raise ArgumentError empty domain concept' do
     131      lambda {
     132        @archetype_id.domain_concept = ''
     133      }.should raise_error ArgumentError
     134    end
     135
     136    it 'should raise ArgumentError nil domain concept' do
     137      lambda {
     138        @archetype_id.domain_concept = nil
     139      }.should raise_error ArgumentError
     140    end
     141
     142    it 's specialisation may be empty' do
     143      @archetype_id.domain_concept = 'clinical_synopsis'
     144      @archetype_id.concept_name.should == 'clinical_synopsis'
     145    end
     146  end
    44147end
Note: See TracChangeset for help on using the changeset viewer.