Changeset 152


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

refs #47

we must clarify HL7 specification

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

Legend:

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

    r140 r152  
    3737      autoload :Quantity, "rm/data_types/quantity.rb"
    3838      autoload :Encapsulated, "rm/data_types/encapsulated.rb"
     39      autoload :Time_Specification, 'rm/data_types/time_specification.rb'
    3940    end
    4041
  • ruby/trunk/lib/models/rm/data_types/time_specification.rb

    r5 r152  
     1# This module is related to the ticket #47
     2
    13module OpenEHR
    24  module RM
     
    46      module Time_Specification
    57        class DV_Time_Specification < OpenEHR::RM::Data_Types::Basic::Data_Value
     8          attr_reader :value
     9
    610          def initialize(value)
     11            self.value=(value)
     12          end
     13
     14          def value=(value)
     15            raise ArgumentError, 'value must be not nil' if value.nil?
    716            @value = value
    817          end
     18         
    919          def calender_alignment
    1020            raise NotImlementedError, "calender_alignment must be implemented"
    1121          end
     22
    1223          def event_alignment
    1324            raise NotImlementedError, "event_alignment must be implemented"
    1425          end
     26
    1527          def institution_specified
    1628            raise NotImlementedError, "institution_specified must be implemented"
    1729          end
    1830        end
    19        
     31
     32
    2033        class DV_General_Time_Specification < DV_Time_Specification
    2134          attr_reader :value
     35          def initialize(value)
     36            super(value)
     37          end
     38          def value=(value)
     39            raise ArgumentError, "value is not valied" unless value.formalism.is_equal?('HL7:GTS')
     40            @value = value
     41          end
     42          private
     43          def value_valid(value)
     44          end
     45        end
     46
     47        class DV_Periodic_Time_Specification < DV_Time_Specification
     48          attr_reader :value, :calender_alignment, :event_alingment, :period
    2249          def initialize(value)
    2350            value_valid(value)
     
    2552          end
    2653          def value=(value)
    27             value_valid(value)
    28             @value = value
     54            unless value.formalism.is_equal('HL7:PIVL') or value.formalism.is_equal('HL7:EIVL')
     55              raise ArgumentError, "value is not valid"
     56            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
    2961          end
    30           private
    31           def value_valid(value)
    32             raise ArgumentError, "value is not valied" if !value.formalism.is_equal?('HL7:GTS')
     62
     63          def calender_alignment
     64
    3365          end
    34         end
    3566
    36         class DV_Periodic_Time_Specification < DV_Time_Specification
    37           attr_reader :value
    38           def initialize(value)
    39             value_valid(value)
    40             super(value)
     67          def event_alignment
     68
    4169          end
    42           def calender_alignment
    43           end
    44           def event_alignment
    45           end
     70
    4671          def institution_specified?
     72
    4773          end
    4874          def period
    49           end
    50           private
    51           def value_valid(value)
    52             if !value.formalism.is_equal('HL7:PIVL') && value.formalism.is_equal('HL7:EIVL')
    53               raise ArgumentError, "value is not valid"
    54             end
    5575          end
    5676        end
  • ruby/trunk/lib/models/tests/rm/test_data_types.rb

    r149 r152  
    426426  end
    427427end
     428
     429
     430class TestDvTimeSpecification < Test::Unit::TestCase
     431  include OpenEHR::RM::Data_Types::Time_Specification
     432  include OpenEHR::RM::Data_Types::Encapsulated
     433  def setup
     434    charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('UTF-8','character-sets')
     435    language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('ja', 'languages')
     436    assert_nothing_raised(Exception){
     437      dv_parsable = DV_Parsable.new(charset, language, 10, 'XML','<TEST>test</TEST>')
     438      @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
     443  end
     444
     445  def test_init
     446    assert_instance_of DV_Time_Specification, @dv_time_specification
     447  end
     448
     449  def test_dv_time_specification
     450    assert_equal '<TEST>test</TEST>', @dv_time_specification.value.value
     451  end
     452end
Note: See TracChangeset for help on using the changeset viewer.