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

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

refs #50
Quantity package is difficult to solve.

File size: 3.6 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
4module OpenEHR
5 module RM
6 module Data_Types
7 module Quantity
8
9 autoload :Date_Time, "rm/data_types/quantity/date_time.rb"
10
11 class DV_Ordered < OpenEHR::RM::Data_Types::Basic::Data_Value
12 include Comparable
13 attr_accessor :normal_range, :other_refference_ranges, :normal_status
14
15 def initialize(normal_range=nil, normal_status = nil,
16 other_reference_ranges=nil)
17 self.normal_range = normal_range
18 self.normal_status = normal_status
19 self.other_reference_ranges = other_reference_ranges
20 end
21
22 def is_normal?
23 if @normal_range.nil? and @normal_status.nil?
24 return false
25 elsif !@normal_range.nil?
26 return @normal_range.has(@value)
27 elsif !@normal_status.nil?
28 return @normal_status.code_string == 'N'
29 end
30 end
31
32 def is_simple?
33 normal_status.nil? and other_refference_ranges.nil?
34 end
35
36 def <=>(other)
37 raise NotImplementedError, 'This method should be implemented'
38 end
39
40 def other_reference_ranges=(other_reference_ranges)
41 unless other_reference_ranges.nil? or !other_reference_ranges.is_empty?
42 raise ArgumentError, "Other reference ranges validity error"
43 end
44
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_Quantified < DV_Ordered
54
55 def initialize(normal_range=nil, normal_status = nil,
56 other_reference_ranges=nil)
57 super(normal_range, normal_status, other_reference_ranges)
58
59
60 end
61
62 def magnitude
63
64 end
65
66 def <=>(others)
67 @symbol.
68 end
69
70 def valid_magnitude_status(s)
71 end
72 end
73
74 class DV_Ordinal < DV_Ordered
75 attr_reader :symbol, :value
76
77 def is_strictly_comparable_to?
78 end
79
80 def <=>(other)
81 @symbol.
82 end
83 def limits
84 end
85 end
86
87 class DV_Absolute_Quantity < DV_Quantified
88 attr_reader :accuracy
89
90 def add(a_diff)
91 raise NotImplementError, 'add must be implemented'
92 end
93
94 def diff(other)
95 raise NotImplementError, 'diff must be implemented'
96 end
97
98 def subtract(a_diff)
99 raise NotImplementError, 'subtract must be implemented'
100 end
101 end
102
103 class DV_Amount < DV_Quantified
104 attr_reader :accuracy, :accuracy_is_percent
105 def infix(dv_amount, op)
106 raise NotImplementError, 'infix must be implemented'
107 end
108 def accuracy=(accuracy)
109 raise ArgumentError, 'accuracy invalid'
110 end
111 end
112
113 class Reference_Range
114
115 end
116
117 module Proportion_Kind
118 PK_RATIO = 0
119 PK_UNITARY = 1
120 PK_PERCENT = 2
121 PK_FRACTION = 3
122 PK_INTEGER_FRACTION = 4
123
124 def Proportion_Kind.valid_proportion_kind?(kind)
125 return true if kind >= 0 && kind <= 4
126 return false
127 end
128 end
129 end # of Quantity
130 end # of Data_Types
131 end # of RM
132end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.