source: ruby/branches/0.5/lib/open_ehr/rm/data_types/basic.rb@ 195

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

refs #54

File size: 2.1 KB
Line 
1# This module is implemented from this UML:
2# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067591791_562382_3151Report.html
3# Ticket refs #52
4module OpenEhr
5 module RM
6 module DataTypes
7 module Basic
8 module CanonicalFragment
9 end
10
11 class DataValue
12 include OpenEhr::RM::Support::Definition::BasicDefinition
13 def ==(other)
14 return self.value == other.value
15 end
16 end
17
18 class DvBoolean < DataValue
19 def initialize(value)
20 self.value = value
21 end
22 def value=(value)
23 raise ArgumentError, "value must not be nil" if value.nil?
24 if value == true or value =~ /TRUE/i
25 @value = true
26 else
27 @value = false
28 end
29 end
30
31 def value?
32 @value == true
33 end
34 end # end of DvBoolean
35
36 class DvState < DataValue
37 attr_reader :value
38
39 def initialize(value, is_terminal)
40 self.value=value
41 self.is_terminal=is_terminal
42 end
43 def value=(v)
44 raise ArgumentError, "value should not be nil" if v.nil?
45 @value = v
46 end
47 def is_terminal?
48 @is_terminal
49 end
50 def is_terminal=(s)
51 raise ArgumentError, "terminal should not be nil" if s.nil?
52 @is_terminal = s
53 end
54 end # end of DvState
55
56 class DvIdentifier
57 attr_accessor :issuer, :assigner, :id, :type
58 def initialize(assigner, id, issuer, type)
59 if assigner.nil? or assigner.empty?\
60 or id.nil? or id.empty? or issuer.nil? or issuer.empty?\
61 or type.nil? or type.empty?
62 raise ArgumentError, "invalid argument"
63 end
64 @issuer = issuer
65 @assigner = assigner
66 @id = id
67 @type = type
68 end
69 end #end of DvIdentifier
70 end # end of Basic
71 end # end of DataTypes
72 end # end of RM
73end # end of OpenEHR
Note: See TracBrowser for help on using the repository browser.