source: ruby/branches/0.5/lib/open_ehr/rm/data_types/time_specification.rb@ 216

Last change on this file since 216 was 216, checked in by KOBAYASHI, Shinji, 15 years ago

move from Test:Unit to RSpec

File size: 2.1 KB
RevLine 
[152]1# This module is related to the ticket #47
2
[216]3module OpenEHR
[4]4 module RM
[167]5 module DataTypes
6 module TimeSpecification
[216]7 class DvTimeSpecification < OpenEHR::RM::DataTypes::Basic::DataValue
[152]8 attr_reader :value
9
[4]10 def initialize(value)
[152]11 self.value=(value)
12 end
13
14 def value=(value)
15 raise ArgumentError, 'value must be not nil' if value.nil?
[4]16 @value = value
17 end
[152]18
[4]19 def calender_alignment
20 raise NotImlementedError, "calender_alignment must be implemented"
21 end
[152]22
[4]23 def event_alignment
24 raise NotImlementedError, "event_alignment must be implemented"
25 end
[152]26
[4]27 def institution_specified
28 raise NotImlementedError, "institution_specified must be implemented"
29 end
30 end
[152]31
[153]32# I have not implemented two classes bellow,
33# because I could not obtain HL7 specification related them.
[152]34
[153]35
[167]36 class DvGeneralTimeSpecification < DvTimeSpecification
[4]37 attr_reader :value
38 def initialize(value)
39 super(value)
40 end
41 def value=(value)
[152]42 raise ArgumentError, "value is not valied" unless value.formalism.is_equal?('HL7:GTS')
[4]43 @value = value
44 end
45 private
46 def value_valid(value)
47 end
48 end
[5]49
[167]50 class DvPeriodicTimeSpecification < DvTimeSpecification
[152]51 attr_reader :value, :calender_alignment, :event_alingment, :period
[5]52 def initialize(value)
53 value_valid(value)
54 super(value)
55 end
[152]56 def value=(value)
57 unless value.formalism.is_equal('HL7:PIVL') or value.formalism.is_equal('HL7:EIVL')
58 raise ArgumentError, "value is not valid"
59 end
[153]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
[152]66 end
67
[5]68 def institution_specified?
[152]69
[5]70 end
71 end
[4]72 end
73 end # of Data_Type
74 end # of RM
75end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.