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
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
[124]12 def initialize(normal_range=nil, normal_status = nil,
13 other_reference_ranges=nil)
[123]14 self.normal_range = normal_range
[124]15 self.normal_status = normal_status
[123]16 self.other_reference_ranges = other_reference_ranges
[4]17 end
[122]18
[4]19 def is_normal?
[124]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
[4]27 end
[122]28
[4]29 def is_simple?
[88]30 normal_status.nil? and other_refference_ranges.nil?
[4]31 end
[122]32
33 def <=>(other)
[124]34 raise NotImplementedError, 'This method should be implemented'
[122]35 end
36
37 def normal_range=(normal_range)
[123]38 @normal_range = normal_range
[122]39 end
40
41 def other_reference_ranges=(other_reference_ranges)
[123]42 unless other_reference_ranges.nil? or !other_reference_ranges.is_empty?
[4]43 raise ArgumentError, "Other reference ranges validity error"
44 end
[123]45
46 @other_reference_ranges = other_reference_ranges
[4]47 end
[123]48
49 def normal_status=(normal_status)
50 @normal_status = normal_status
51 end
52
[4]53 end
[88]54
[104]55 class DV_Quantified < DV_Ordered
[4]56 def magnitude
57 end
58 def valid_magnitude_status(s)
59 end
60 end
[88]61
[104]62 class DV_Ordinal < DV_Ordered
[88]63 attr_reader :symbol, :value
64 def is_strictly_comparable_to?
65 end
66 def limits
67 end
68 end
69
[104]70 class DV_Absolute_Quantity < DV_Quantified
[88]71 attr_reader :accuracy
72
73 def add(a_diff)
[122]74 raise NotImplementError, 'add must be implemented'
[88]75 end
76
77 def diff(other)
[122]78 raise NotImplementError, 'diff must be implemented'
[88]79 end
80
81 def subtract(a_diff)
[122]82 raise NotImplementError, 'subtract must be implemented'
[88]83 end
84 end
[120]85
[122]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
[124]96 class Reference_Range
97
98 end
99
[120]100 autoload :Date_Time, "rm/data_types/quantity/date_time.rb"
101
[4]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.