Changeset 262 for ruby/branches/0.5
- Timestamp:
- Sep 14, 2009, 7:10:46 PM (15 years ago)
- 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 49 49 50 50 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 61 94 end 62 95 63 96 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 66 106 end 67 107 … … 72 112 73 113 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 75 117 @rm_entity = rm_entity 76 118 end 77 119 78 120 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 80 124 @rm_originator = rm_originator 81 125 end 82 126 83 127 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 85 131 @specialisation = specialisation 86 132 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'1 require File.dirname(__FILE__) + '/../../../../../spec_helper' 2 2 include OpenEHR::RM::Support::Identification 3 3
Note:
See TracChangeset
for help on using the changeset viewer.