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

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

refs #50
Quantity package is difficult to solve.

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