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

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

refs #50
Quantity package is difficult to solve.

File size: 3.4 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 normal_range=(normal_range)
41 @normal_range = normal_range
42 end
43
44 def other_reference_ranges=(other_reference_ranges)
45 unless other_reference_ranges.nil? or !other_reference_ranges.is_empty?
46 raise ArgumentError, "Other reference ranges validity error"
47 end
48
49 @other_reference_ranges = other_reference_ranges
50 end
51
52 def normal_status=(normal_status)
53 @normal_status = normal_status
54 end
55
56 def is_strictry_comparable_to?(other)
57 raise NotImplementedError, 'this method should be implemented'
58 end
59 end
60
61 class DV_Quantified < DV_Ordered
62
63 def initialize(normal_range=nil, normal_status = nil,
64 other_reference_ranges=nil)
65
66
67 end
68
69 def magnitude
70
71 end
72
73 def <=>(others)
74
75 end
76
77 def valid_magnitude_status(s)
78 end
79 end
80
81 class DV_Ordinal < DV_Ordered
82 attr_reader :symbol, :value
83
84 def is_strictly_comparable_to?
85 end
86
87 def limits
88 end
89 end
90
91 class DV_Absolute_Quantity < DV_Quantified
92 attr_reader :accuracy
93
94 def add(a_diff)
95 raise NotImplementError, 'add must be implemented'
96 end
97
98 def diff(other)
99 raise NotImplementError, 'diff must be implemented'
100 end
101
102 def subtract(a_diff)
103 raise NotImplementError, 'subtract must be implemented'
104 end
105 end
106
107 class DV_Amount < DV_Quantified
108 attr_reader :accuracy, :accuracy_is_percent
109 def infix(dv_amount, op)
110 raise NotImplementError, 'infix must be implemented'
111 end
112 def accuracy=(accuracy)
113 raise ArgumentError, 'accuracy invalid'
114 end
115 end
116
117 class Reference_Range
118
119 end
120 end # of Quantity
121 end # of Data_Types
122 end # of RM
123end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.