Changeset 262 for ruby/branches


Ignore:
Timestamp:
Sep 14, 2009, 7:10:46 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

archetype id corrected

Location:
ruby/branches/0.5
Files:
1 added
2 edited

Legend:

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

    r259 r262  
    4949
    5050        class ArchetypeID < ObjectID
    51           attr_reader :domain_concept, :rm_name, :rm_entity, :rm_originator, :specialisation, :version_id
    52 
    53           def initialize(value, domain_concept, rm_name, rm_entity, rm_originator, specialisation, version_id)
    54             super(value)
    55             self.domain_concept = domain_concept
    56             self.rm_name = rm_name
    57             self.rm_entity = rm_entity
    58             self.rm_originator = rm_originator
    59             self.specialisation = specialisation
    60             self.version_id = version_id
     51          attr_reader :rm_originator, :rm_name, :rm_entity,
     52                      :concept_name, :specialisation, :version_id
     53         
     54          def initialize(args = {})
     55            super(args)
     56            if args[:value].nil?
     57              self.rm_originator = args[:rm_originator]
     58              self.rm_name = args[:rm_name]
     59              self.rm_entity = args[:rm_entity]
     60              self.concept_name = args[:concept_name]
     61              self.version_id = args[:version_id]
     62              self.specialisation = args[:specialisation]
     63            else
     64              self.value = args[:value]
     65            end
     66          end
     67
     68          def value=(value)
     69            if /([a-zA-Z]\w+)-([a-zA-Z]\w+)-([a-zA-Z]\w+)\.([a-zA-Z]\w+)(-([a-zA-Z]\w+))?\.(v[1-9]\d*)/ =~ value
     70              self.rm_originator = $1
     71              self.rm_name = $2
     72              self.rm_entity = $3
     73              self.concept_name = $4
     74              self.specialisation = $6
     75              self.version_id = $7
     76            else
     77              raise ArgumentError, 'invalid archetype id form'
     78            end
     79          end
     80
     81          def qualified_rm_entity
     82            return @rm_originator + '-' + @rm_name + '-' + @rm_entity
     83          end
     84
     85          def domain_concept
     86            return @concept_name + '-' + @specialisation
     87          end
     88
     89          def concept_name=(concept_name)
     90            if concept_name.nil? or concept_name.empty?
     91              raise ArgumentError, 'concept_name is mandatory'
     92            end
     93            @concept_name = concept_name
    6194          end
    6295
    6396          def domain_concept=(domain_concept)
    64             raise ArgumentError, "domain concept not valid" if domain_concept.nil? or domain_concept.empty?
    65             @domain_concept = domain_concept
     97            if domain_concept.nil? or domain_concept.empty?
     98              raise ArgumentError, "domain concept not valid"
     99            end
     100            if /([a-zA-Z]\w+)(-([a-zA-Z]\w))?/ =~ domain_concept
     101              self.concept_name = $1
     102              self.specialisation = $3
     103            else
     104              raise ArgumentError, 'invalid domain concept form'
     105            end
    66106          end
    67107
     
    72112
    73113          def rm_entity=(rm_entity)
    74             raise ArgumentError, "rm_entity not valid" if rm_entity.nil? or rm_entity.empty?
     114            if rm_entity.nil? or rm_entity.empty?
     115              raise ArgumentError, "rm_entity is mandatory"
     116            end
    75117            @rm_entity = rm_entity
    76118          end
    77119
    78120          def rm_originator=(rm_originator)
    79             raise ArgumentError, "rm_originator not valid" if rm_originator.nil? or rm_originator.empty?
     121            if rm_originator.nil? or rm_originator.empty?
     122              raise ArgumentError, "rm_originator not valid"
     123            end
    80124            @rm_originator = rm_originator
    81125          end
    82126
    83127          def specialisation=(specialisation)
    84             raise ArgumentError, "rm_specialisation not valid" if specialisation.nil? or specialisation.empty?
     128            if !specialisation.nil? and specialisation.empty?
     129              raise ArgumentError, "rm_specialisation not valid"
     130            end
    85131            @specialisation = specialisation
    86132          end
  • ruby/branches/0.5/spec/lib/open_ehr/rm/support/identification/object_id_spec.rb

    r260 r262  
    1 require File.dirname(__FILE__) + '/../../../../spec_helper'
     1require File.dirname(__FILE__) + '/../../../../../spec_helper'
    22include OpenEHR::RM::Support::Identification
    33
Note: See TracChangeset for help on using the changeset viewer.