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

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

#refs #50

File size: 2.7 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, other_reference_ranges=nil,
13 normal_status = nil)
14 other_reference_ranges_validity(other_reference_ranges)
15 @normal_range = normal_range
16 @other_reference_ranges = other_reference_ranges
17 @normal_status = normal_status
18 end
19
20 def is_normal?
21 !normal_range.nil? or !normal_status.nil
22 end
23
24 def is_simple?
25 normal_status.nil? and other_refference_ranges.nil?
26 end
27
28 def <=>(other)
29 raise NotImplementError, 'This method should be implemented'
30 end
31
32 def normal_range=(normal_range)
33 end
34
35 def other_reference_ranges=(other_reference_ranges)
36 end
37
38 private
39 def other_reference_ranges_validity(other_reference_ranges)
40 if !other_reference_ranges.nil? or other_reference_ranges.is_empty?
41 raise ArgumentError, "Other reference ranges validity error"
42 end
43 end
44 end
45
46 class DV_Quantified < DV_Ordered
47 def magnitude
48 end
49 def valid_magnitude_status(s)
50 end
51 end
52
53 class DV_Ordinal < DV_Ordered
54 attr_reader :symbol, :value
55 def is_strictly_comparable_to?
56 end
57 def limits
58 end
59 end
60
61 class DV_Absolute_Quantity < DV_Quantified
62 attr_reader :accuracy
63
64 def add(a_diff)
65 raise NotImplementError, 'add must be implemented'
66 end
67
68 def diff(other)
69 raise NotImplementError, 'diff must be implemented'
70 end
71
72 def subtract(a_diff)
73 raise NotImplementError, 'subtract must be implemented'
74 end
75 end
76
77 class DV_Amount < DV_Quantified
78 attr_reader :accuracy, :accuracy_is_percent
79 def infix(dv_amount, op)
80 raise NotImplementError, 'infix must be implemented'
81 end
82 def accuracy=(accuracy)
83 raise ArgumentError, 'accuracy invalid'
84 end
85 end
86
87 autoload :Date_Time, "rm/data_types/quantity/date_time.rb"
88
89 end # of Quantity
90 end # of Data_Types
91 end # of RM
92end # of OpenEHR
Note: See TracBrowser for help on using the repository browser.