source: ruby/trunk/lib/models/rm/data_types/quantity.rb@ 141

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

refs #50

File size: 4.2 KB
Line 
1# This modules are implemented from the UML shown bellow
2# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109599337877_94556_1510Report.html
3# Ticket refs #50
4require 'assumed_library_types'
5module OpenEHR
6 module RM
7 module Data_Types
8 module Quantity
9
10 autoload :Date_Time, "rm/data_types/quantity/date_time.rb"
11
12 class DV_Ordered < OpenEHR::RM::Data_Types::Basic::Data_Value
13 include Comparable
14 attr_accessor :normal_range, :other_refference_ranges, :normal_status
15
16 def initialize(normal_range=nil, normal_status = nil,
17 other_reference_ranges=nil)
18 self.normal_range = normal_range
19 self.normal_status = normal_status
20 self.other_reference_ranges = other_reference_ranges
21 end
22
23 def is_normal?
24 if @normal_range.nil? and @normal_status.nil?
25 return false
26 elsif !@normal_range.nil?
27 return @normal_range.has(@value)
28 elsif !@normal_status.nil?
29 return @normal_status.code_string == 'N'
30 end
31 end
32
33 def is_simple?
34 normal_status.nil? and other_refference_ranges.nil?
35 end
36
37 def <=>(other)
38 raise NotImplementedError, 'This method should be implemented'
39 end
40
41 def other_reference_ranges=(other_reference_ranges)
42 unless other_reference_ranges.nil? or !other_reference_ranges.is_empty?
43 raise ArgumentError, "Other reference ranges validity error"
44 end
45 @other_reference_ranges = other_reference_ranges
46 end
47
48 def is_strictry_comparable_to?(other)
49 raise NotImplementedError, 'this method should be implemented'
50 end
51 end
52
53 class DV_Interval < OpenEHR::Assumed_Library_Types::Interval
54
55 end
56
57 class DV_Quantified < DV_Ordered
58
59 def initialize(normal_range=nil, normal_status = nil,
60 other_reference_ranges=nil)
61 super(normal_range, normal_status, other_reference_ranges)
62 end
63
64 def magnitude
65
66 end
67
68 def <=>(others)
69 @value <=> others.value
70 end
71
72 def valid_magnitude_status(s)
73
74 end
75 end
76
77 class DV_Ordinal < DV_Ordered
78 attr_reader :value, :symbol
79 def initialize(value, symbol, normal_range=nil, normal_status = nil,
80 other_reference_ranges=nil)
81 end
82
83 def is_strictly_comparable_to?
84
85 end
86
87 def <=>(other)
88 @value <=> other.value
89 end
90
91 def limits
92
93 end
94 end
95
96 class DV_Absolute_Quantity < DV_Quantified
97 attr_reader :accuracy
98
99 def add(a_diff)
100 raise NotImplementError, 'add must be implemented'
101 end
102
103 def diff(other)
104 raise NotImplementError, 'diff must be implemented'
105 end
106
107 def subtract(a_diff)
108 raise NotImplementError, 'subtract must be implemented'
109 end
110 end
111
112 class DV_Amount < DV_Quantified
113 attr_reader :accuracy, :accuracy_is_percent
114
115 def infix(dv_amount, op)
116 raise NotImplementError, 'infix must be implemented'
117 end
118
119 def accuracy=(accuracy)
120 raise ArgumentError, 'accuracy invalid'
121 end
122 end
123
124 class DV_Quantity < DV_Amount
125
126 end
127
128 class Reference_Range
129 attr_reader :meaning
130
131 def initialize(meaning)
132 self.meaning = meaning
133 end
134
135 def meaning=(meaning)
136 if meaning.nil?
137 raise ArgumentError, 'meaning should not be nil'
138 end
139 @meaning = meaning
140 end
141 end
142
143 module Proportion_Kind
144 PK_RATIO = 0
145 PK_UNITARY = 1
146 PK_PERCENT = 2
147 PK_FRACTION = 3
148 PK_INTEGER_FRACTION = 4
149
150 def Proportion_Kind.valid_proportion_kind?(kind)
151 return true if kind >= 0 && kind <= 4
152 return false
153 end
154 end # end of Proportion_Kind
155 end # of Quantity
156 end # of Data_Types
157 end # of RM
158end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.