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
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
[104]8 class DV_Ordered < OpenEHR::RM::Data_Types::Basic::Data_Value
[4]9 include Comparable
[122]10 attr_reader :other_refference_ranges, :normal_range, :normal_status
11
12 def initialize(normal_range=nil, other_reference_ranges=nil,
[4]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
[122]19
[4]20 def is_normal?
[88]21 !normal_range.nil? or !normal_status.nil
[4]22 end
[122]23
[4]24 def is_simple?
[88]25 normal_status.nil? and other_refference_ranges.nil?
[4]26 end
[122]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
[4]38 private
39 def other_reference_ranges_validity(other_reference_ranges)
[88]40 if !other_reference_ranges.nil? or other_reference_ranges.is_empty?
[4]41 raise ArgumentError, "Other reference ranges validity error"
42 end
43 end
44 end
[88]45
[104]46 class DV_Quantified < DV_Ordered
[4]47 def magnitude
48 end
49 def valid_magnitude_status(s)
50 end
51 end
[88]52
[104]53 class DV_Ordinal < DV_Ordered
[88]54 attr_reader :symbol, :value
55 def is_strictly_comparable_to?
56 end
57 def limits
58 end
59 end
60
[104]61 class DV_Absolute_Quantity < DV_Quantified
[88]62 attr_reader :accuracy
63
64 def add(a_diff)
[122]65 raise NotImplementError, 'add must be implemented'
[88]66 end
67
68 def diff(other)
[122]69 raise NotImplementError, 'diff must be implemented'
[88]70 end
71
72 def subtract(a_diff)
[122]73 raise NotImplementError, 'subtract must be implemented'
[88]74 end
75 end
[120]76
[122]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
[120]87 autoload :Date_Time, "rm/data_types/quantity/date_time.rb"
88
[4]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.