Changeset 106 for ruby/trunk/lib/models
- Timestamp:
- Sep 27, 2008, 1:12:51 PM (16 years ago)
- Location:
- ruby/trunk/lib/models
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/lib/models/rm/data_types/basic.rb
r89 r106 15 15 class DV_Boolean < Data_Value 16 16 def initialize(value) 17 check_not_nil(value) 17 self.value = value 18 end 19 def value=(value) 20 raise ArgumentError, "value must not be nil" if value.nil? 18 21 if value == "TRUE" or value == true 19 22 @value = true … … 22 25 end 23 26 end 24 def value=(value)25 check_not_nil(value)26 @value = value27 end28 27 def value? 29 28 @value == true 30 end31 private32 def check_not_nil(value)33 if value == nil34 raise ArgumentError, "value must not be empty"35 end36 29 end 37 30 end # end of DV_Boolean … … 55 48 @is_terminal = s 56 49 end 57 private58 def value_validity?59 @value.instance_of? OpenEHR::Data_Types::Text::DV_Coded_Text60 end61 50 end # end of DV_State 62 51 … … 64 53 attr_accessor :issuer, :assigner, :id, :type 65 54 def initialize(assigner, id, issuer, type) 66 if assigner == nil or id == nil or issuer == nil or type == nil 55 if assigner.nil? or assigner.empty?\ 56 or id.nil? or id.empty? or issuer.nil? or issuer.empty?\ 57 or type.nil? or type.empty? 67 58 raise ArgumentError, "invalid argument" 68 59 end -
ruby/trunk/lib/models/rm/data_types/text.rb
r90 r106 47 47 attr_reader :terminology_id, :code_string 48 48 def initialize(terminology_id, code_string) 49 if terminlogyID.nil?50 raise Exception.new("nil terminology")51 52 if code_string.nil? 53 raise Exception.new("empty codeString")54 end55 if terminology_id.instance_of?(Terminology_ID)56 @terminology_id = terminology_id57 else 58 @terminologyID = Terminology_ID.new(terminology_id)59 end49 self.terminology_id = terminology_id 50 self.code_string = code_string 51 end 52 53 def terminology_id=(terminology_id) 54 raise ArgumentError, "terminology_id should not be nil" if terminology_id.nil? 55 @terminology_id = terminology_id 56 end 57 58 def code_string=(code_string) 59 raise ArgumentError, "code_string should not be empty" if code_string.nil? or code_string.empty? 60 60 @code_string = code_string 61 end 61 end 62 62 end # of Code_Phrase 63 63 -
ruby/trunk/lib/models/rm/support/identification.rb
r102 r106 95 95 96 96 def initialize(value, name , version_id="") 97 s uper(value)97 self.value = value 98 98 self.name = name 99 99 self.version_id = version_id 100 end 101 102 def value = (value) 103 raise ArgumentError, "value not valid" if value.nil? or value.empty? 104 if /(.*)(\(.*\)$)/ = value 105 @name = $1 106 @version_id = $2 107 else 108 @name = value 109 end 110 @value = value 100 111 end 101 112 … … 103 114 raise ArgumentError, "name not valid" if name.nil? or name.empty? 104 115 @name = name 116 if @version_id.empty? 117 @value = name 118 else 119 @value = name + '(' + value ')' 120 end 105 121 end 106 122 -
ruby/trunk/lib/models/tests/test_reference_model.rb
r105 r106 352 352 class RM_Data_Types_Basic_Test < Test::Unit::TestCase 353 353 def setup 354 @dv_boolean = OpenEHR::RM::Data_Types::Basic::DV_Boolean.new("TRUE") 355 @dv_state = OpenEHR::RM::Data_Types::Basic::DV_State.new("code1",true) 354 assert_nothing_raised(Exception){@dv_boolean = OpenEHR::RM::Data_Types::Basic::DV_Boolean.new("TRUE")} 355 @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('C83.3', 'ICD10','') 356 @code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase(@terminology_id, 357 @dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text 358 @dv_state = OpenEHR::RM::Data_Types::Basic::DV_State.new(OpenEHR::RM::Data_Types::Text:DV_Coded_Text.new("Chronic myeloid leukemia", @terminology_id), true) 356 359 @dv_identifier = OpenEHR::RM::Data_Types::Basic::DV_Identifier.new("Ruby Hospital","0123456-0", "Information office", "personal id") 357 360 end … … 433 436 class RM_Data_Types_Text_Test < Test::Unit::TestCase 434 437 def setup 435 @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new("valid value") 436 @dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new("valid value", "AT1000") 438 assert_nothing_raised(Exception){@dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new("valid value")} 439 @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID('ICD10', '') 440 assert_nothing_raised(Exception){@dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new("C82.3", @terminology_id)} 437 441 @dv_paragraph = OpenEHR::RM::Data_Types::Text::DV_Paragraph.new(Set.new(["test1", "test2"])) 438 442 @term_mapping = OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',@dv_coded_text,"TEST") … … 459 463 460 464 def test_dv_coded_text 461 assert_equal(" valid value", @dv_coded_text.value)462 assert_equal(" AT1000", @dv_coded_text.defining_code)465 assert_equal("C83.2", @dv_coded_text.value) 466 assert_equal("ICD10", @dv_coded_text.defining_code) 463 467 assert_raise(ArgumentError){@dv_coded_text.defining_code=nil} 464 468 end
Note:
See TracChangeset
for help on using the changeset viewer.