Changeset 153


Ignore:
Timestamp:
Jul 3, 2009, 2:17:43 AM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #62, #47, #65

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

Legend:

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

    r131 r153  
    138138
    139139        class Feeder_Audit_Details
     140          attr_reader :system_id
    140141
     142          def initialize(args ={ })
     143            self.system_id = args[:system_id]
     144          end
     145
     146          def system_id=(system_id)
     147            raise ArgumentError, 'system_id invalid' if system_id.nil? or system_id.empty?
     148            @system_id = system_id
     149          end
    141150        end # of Feeder_Audit_Details
    142151      end # of Archetyped
  • ruby/trunk/lib/models/rm/common/generic.rb

    r104 r153  
    22# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140169202660_257304_813Report.html
    33# Related to the ticket #62
     4include OpenEHR::RM::Support::Identification
     5include OpenEHR::RM::Data_Types::Basic
    46module OpenEHR
    57  module RM
     
    1719
    1820        class Party_Proxy
    19           def external_ref
    20             Raise NotImplementedError, 'external_ref shoud provide Party_Ref'
     21          attr_accessor :external_ref
     22
     23          def initialize(args = { })
     24            self.external_ref = args[:external_ref]
    2125          end
    2226        end
     
    2731
    2832        class Party_Identified < Party_Proxy
     33          attr_reader :name, :identifier
     34          def initialize(args = { })
     35            if args[:external_ref].nil? && args[:name].nil? &&
     36                args[:identifier].nil?
     37              raise ArgumentError, 'cannot identified'
     38            end
     39            super(:external_ref => args[:external_ref])
     40            self.name = args[:name]
     41            self.identifier = args[:identifier]
     42          end
    2943
     44          def name=(name)
     45            if name.nil? && @external_ref.nil? && @identifier.nil?
     46              raise ArgumentError, 'cannot identified'
     47            end
     48            raise ArgumentError, 'invaild name' unless name.nil? || !name.empty?
     49            @name = name
     50          end
     51
     52          def identifier=(identifier)
     53            if @name.nil? && @external_ref.nil? && identifier.nil?
     54              raise ArgumentError, 'cannot identified'
     55            end
     56            unless identifier.nil? || !identifier.empty?
     57              raise ArgumentError, 'invaild identifier'
     58            end
     59            @identifier = identifier
     60          end
    3061        end
    3162
  • ruby/trunk/lib/models/rm/data_types/time_specification.rb

    r152 r153  
    3030        end
    3131
     32# I have not implemented two classes bellow,
     33# because I could not obtain HL7 specification related them.
     34
    3235
    3336        class DV_General_Time_Specification < DV_Time_Specification
     
    5558              raise ArgumentError, "value is not valid"
    5659            end
    57             /^\[(\d+)\;?(\d+)?\]\/\((\d+\w+)\)(@(\w+?))?(IST)?$/ =~ value
    58             interval1, interval2, difference, allignment = $1, $2, $3, $5
    59 # not implemented because of unknown HL7 specification
    60 
    61           end
    62 
    63           def calender_alignment
    64 
    65           end
    66 
    67           def event_alignment
    68 
     60            if value.formalism('HL7:PIVL')
     61              /^\[(\d+)\;?(\d+)?\]\/\((\d+\w+)\)(@(\w+?))?(IST)?$/ =~ value
     62              interval1, interval2, difference, allignment = $1, $2, $3, $5
     63            end
     64            if value
     65            end
    6966          end
    7067
    7168          def institution_specified?
    7269
    73           end
    74           def period
    7570          end
    7671        end
  • ruby/trunk/lib/models/tests/rm/test_common.rb

    r128 r153  
    22require 'set'
    33require 'rm'
     4
     5include OpenEHR::RM::Data_Types::Text
     6include OpenEHR::RM::Common::Resource
     7include OpenEHR::RM::Common::Archetyped
    48
    59class RM_Common_Resource_Test < Test::Unit::TestCase
     
    1519  end
    1620
     21  def test_authoured_resource
     22    assert_equal 'ja', @authored_resource.original_language
     23  end
    1724end
    1825
     
    3138    assert_nothing_raised(Exception){
    3239      @locatable = OpenEHR::RM::Common::Archetyped::Locatable.new('at0001',name,links)}
     40    assert_nothing_raised(Exception){
     41      @feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'MAGI')}
    3342  end
    3443
     
    3847    assert_instance_of OpenEHR::RM::Common::Archetyped::Pathable, @pathable
    3948    assert_instance_of OpenEHR::RM::Common::Archetyped::Locatable, @locatable
     49    assert_instance_of Feeder_Audit_Details, @feeder_audit_details
    4050  end
    4151
     
    7383    assert_raise(ArgumentError){@link.type = nil}
    7484  end
     85
     86  def test_feeder_audit
     87  end
     88
     89  def test_feeder_audit_detail
     90    assert_equal 'MAGI', @feeder_audit_details.system_id
     91  end
    7592end
    7693
    7794class RM_Common_Generic_Test < Test::Unit::TestCase
     95  include OpenEHR::RM::Common::Generic
     96  include OpenEHR::RM::Support::Identification
     97  include OpenEHR::RM::Data_Types::Basic
    7898  def setup
    79 #    assert_nothing_raised(Exception){@party_proxy = OpenEHR::RM::Common::Generic::Party_Proxy.new}
     99    assert_nothing_raised(Exception){party_proxy = Party_Proxy.new}
     100    object_id = Object_ID.new('0.0.4')
     101    party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
     102    assert_nothing_raised(Exception){
     103      @party_proxy = Party_Proxy.new(:external_ref => party_ref)}
     104    assert_nothing_raised(Exception){party_self = Party_Self.new}
     105    assert_nothing_raised(Exception){
     106      @party_self = Party_Self.new(:external_ref => party_ref)}
     107    assert_raise(ArgumentError){
     108      party_identified = Party_Identified.new}
     109    identifiers = []
     110    identifiers << DV_Identifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
     111    identifiers << DV_Identifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
     112    identifiers << DV_Identifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
     113    assert_nothing_raised(Exception){
     114      @party_identified = Party_Identified.new(:name => 'NERV',
     115                                               :external_ref => party_ref,
     116                                               :identifier => identifiers)}
    80117#    change_type = OpenEHR::RM::Data_Types::Text::DV_Text.new('audit_type')
    81118#    time_committed = OpenEHR::RM::Data_Types::Quantity::Date_Time::DV_Date_Time.new(2008)
    82119#    assert_nothing_raised(Exception){@audit_details = OpenEHR::RM::Common::Generic::Audit_Details.new('rails',@party_proxy, change_type, time_committed)}
    83120  end
     121
    84122  def test_init
     123    assert_instance_of Party_Proxy, @party_proxy
     124    assert_instance_of Party_Self, @party_self
     125    assert_instance_of Party_Identified, @party_identified
     126  end
     127
     128  def test_party_proxy
     129    assert_equal 'unknown', @party_proxy.external_ref.namespace
     130  end
     131
     132  def test_party_self
     133    assert_equal 'ORGANISATION', @party_self.external_ref.type
     134  end
     135
     136  def test_party_identified
     137    assert_equal 'NERV', @party_identified.name
     138    assert_equal '0.0.4', @party_identified.external_ref.id.value
     139    identifiers = @party_identified.identifier
     140    ids = [ ]
     141    identifiers.each do |id|
     142      ids << id.id
     143    end
     144    assert_equal %w[MELCHIOR CASPER BALTHAZAR], ids
    85145  end
    86146end
  • ruby/trunk/lib/models/tests/rm/test_data_types.rb

    r152 r153  
    437437      dv_parsable = DV_Parsable.new(charset, language, 10, 'XML','<TEST>test</TEST>')
    438438      @dv_time_specification = DV_Time_Specification.new(dv_parsable)}
    439    
    440     assert_nothing_raised(Exception){
    441       @dv_periodic_time_specification = Dv_Periodic_Time_Specification.new(
    442            charset, language, 10, 'PIVL
     439#    assert_nothing_raised(Exception){
     440#      @dv_periodic_time_specification = DV_Periodic_Time_Specification.new('[200004181100;200004181110]/(7d)@DWIST', charset, language, 10, 'HL7:PIVL')}
    443441  end
    444442
Note: See TracChangeset for help on using the changeset viewer.