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

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

refs #48,#50

File size: 3.0 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 class DV_Ordered < OpenEHR::RM::Data_Types::Basic::Data_Value
9 include Comparable
10 attr_reader :other_refference_ranges, :normal_range, :normal_status
11
12 def initialize(normal_range=nil, normal_status = nil,
13 other_reference_ranges=nil)
14 self.normal_range = normal_range
15 self.normal_status = normal_status
16 self.other_reference_ranges = other_reference_ranges
17 end
18
19 def is_normal?
20 if @normal_range.nil? and @normal_status.nil?
21 return false
22 elsif !@normal_range.nil?
23 return @normal_range.has(@value)
24 elsif !@normal_status.nil?
25 return @normal_status.code_string == 'N'
26 end
27 end
28
29 def is_simple?
30 normal_status.nil? and other_refference_ranges.nil?
31 end
32
33 def <=>(other)
34 raise NotImplementedError, 'This method should be implemented'
35 end
36
37 def normal_range=(normal_range)
38 @normal_range = normal_range
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
46 @other_reference_ranges = other_reference_ranges
47 end
48
49 def normal_status=(normal_status)
50 @normal_status = normal_status
51 end
52
53 end
54
55 class DV_Quantified < DV_Ordered
56 def magnitude
57 end
58 def valid_magnitude_status(s)
59 end
60 end
61
62 class DV_Ordinal < DV_Ordered
63 attr_reader :symbol, :value
64 def is_strictly_comparable_to?
65 end
66 def limits
67 end
68 end
69
70 class DV_Absolute_Quantity < DV_Quantified
71 attr_reader :accuracy
72
73 def add(a_diff)
74 raise NotImplementError, 'add must be implemented'
75 end
76
77 def diff(other)
78 raise NotImplementError, 'diff must be implemented'
79 end
80
81 def subtract(a_diff)
82 raise NotImplementError, 'subtract must be implemented'
83 end
84 end
85
86 class DV_Amount < DV_Quantified
87 attr_reader :accuracy, :accuracy_is_percent
88 def infix(dv_amount, op)
89 raise NotImplementError, 'infix must be implemented'
90 end
91 def accuracy=(accuracy)
92 raise ArgumentError, 'accuracy invalid'
93 end
94 end
95
96 class Reference_Range
97
98 end
99
100 autoload :Date_Time, "rm/data_types/quantity/date_time.rb"
101
102 end # of Quantity
103 end # of Data_Types
104 end # of RM
105end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.