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

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

refs #50

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