Changeset 102 for ruby/trunk


Ignore:
Timestamp:
Sep 20, 2008, 12:09:11 PM (16 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #39, #65

Location:
ruby/trunk/lib/models
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/models/rm.rb

    r90 r102  
    1616    module Common
    1717      autoload :Resource, "rm/common/resource.rb"
     18      autoload :Archetyped, "rm/common/archetyped"
    1819    end
    1920
  • ruby/trunk/lib/models/rm/common/archetyped.rb

    r8 r102  
     1# This module is based on the UML,
     2# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109318114715_211173_0Report.html
     3# Ticket refs #65
    14module OpenEHR
    25  module RM
     
    1013          MULTIPART_ID_DELIMITER = "::"
    1114        end
     15
    1216        class Pathable
    13           attr_reader :parent
    14           def initialize(parent)
     17          attr_accessor :parent
     18          def initialize(parent = nil)
    1519            @parent = parent
    1620          end
     
    3135          end
    3236        end
     37
    3338        class Locatable < Pathable
    3439          include Locater_Constants
     
    7681          end
    7782        end
     83        class Archetyped
     84          attr_reader :archetype_id, :rm_version
     85          attr_accessor :template_id
     86          def initialize(archetype_id, rm_version, template_id = nil)           
     87            self.archetype_id = archetype_id
     88            self.rm_version = rm_version
     89            @template_id = template_id
     90          end
     91          def archetype_id=(archetype_id)
     92            raise ArgumentError, "invalid archetype_id" if archetype_id.nil?
     93            @archetype_id = archetype_id
     94          end
     95          def rm_version=(rm_version)
     96            raise ArgumentError, "invalid rm_version" if rm_version.nil? or rm_version.empty?
     97            @rm_version = rm_version
     98          end
     99        end
    78100      end # end of Archetyped
    79101    end # end of Common
  • ruby/trunk/lib/models/rm/support/identification.rb

    r101 r102  
    202202          def value=(value)
    203203            raise ArgumentError, 'value invalid' if value.nil? or value.empty?
    204             @value = value
    205204            @trunk_version = @branch_number = @branch_version = nil
    206205            (trunk_version, branch_number, branch_version) = value.split '.'
  • ruby/trunk/lib/models/tests/test_reference_model.rb

    r101 r102  
    407407  end
    408408end
     409
     410class RM_Common_Archetyped_Test < Test::Unit::TestCase
     411  def setup
     412    @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
     413    @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
     414    @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
     415    @template_id = OpenEHR::RM::Support::Identification::Template_ID.new('1.0.1')
     416    assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
     417   
     418  end
     419  def test_init
     420    assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
     421  end
     422  def test_archetyped
     423    assert_equal @archetype_id, @archetyped.archetype_id
     424    assert_equal '1.0.1', @archetyped.rm_version
     425    assert_raise(ArgumentError){@archetyped.archetype_id = nil}
     426    assert_raise(ArgumentError){@archetyped.rm_version = nil}
     427    assert_raise(ArgumentError){@archetyped.rm_version = ''}
     428    assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
     429    assert_equal @template_id, @archetyped.template_id
     430    archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
     431    assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
     432    assert_equal archetype_id2, @archetyped.archetype_id
     433    assert_nothing_raised(ArgumentError){@archetyped.rm_version = '1.0.2'}
     434    assert_equal '1.0.2', @archetyped.rm_version
     435  end
     436end
Note: See TracChangeset for help on using the changeset viewer.