Changeset 167 for ruby/branches/0.5.0/lib/open_ehr/rm/data_types
- Timestamp:
- Aug 6, 2009, 1:20:05 AM (15 years ago)
- Location:
- ruby/branches/0.5.0/lib/open_ehr/rm/data_types
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5.0/lib/open_ehr/rm/data_types/basic.rb
r109 r167 2 2 # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067591791_562382_3151Report.html 3 3 # Ticket refs #52 4 module OpenE HR4 module OpenEhr 5 5 module RM 6 module Data _Types6 module DataTypes 7 7 module Basic 8 module Canonical _Fragment8 module CanonicalFragment 9 9 end 10 10 11 class Data _Value12 include OpenE HR::RM::Support::Definition::Basic_Definition11 class DataValue 12 include OpenEhr::RM::Support::Definition::BasicDefinition 13 13 end 14 14 15 class D V_Boolean < Data_Value15 class DvBoolean < DataValue 16 16 def initialize(value) 17 17 self.value = value … … 28 28 @value == true 29 29 end 30 end # end of D V_Boolean30 end # end of DvBoolean 31 31 32 class D V_State < Data_Value32 class DvState < DataValue 33 33 attr_reader :value 34 34 … … 48 48 @is_terminal = s 49 49 end 50 end # end of D V_State50 end # end of DvState 51 51 52 class D V_Identifier52 class DvIdentifier 53 53 attr_accessor :issuer, :assigner, :id, :type 54 54 def initialize(assigner, id, issuer, type) … … 63 63 @type = type 64 64 end 65 end #end of D V_Identifier65 end #end of DvIdentifier 66 66 end # end of Basic 67 end # end of Data _types67 end # end of DataTypes 68 68 end # end of RM 69 69 end # end of OpenEHR -
ruby/branches/0.5.0/lib/open_ehr/rm/data_types/encapsulated.rb
r134 r167 5 5 require 'locale/info' 6 6 7 module OpenE HR7 module OpenEhr 8 8 module RM 9 module Data _Types9 module DataTypes 10 10 module Encapsulated 11 class D V_Encapsulated < OpenEHR::RM::Data_Types::Basic::Data_Value11 class DvEncapsulated < OpenEhr::RM::DataTypes::Basic::DataValue 12 12 attr_reader :language, :charset, :size 13 13 def initialize(charset, language, size) … … 59 59 60 60 # media type http://www.iana.org/assignments/media-types/text/ 61 class D V_Multimedia < DV_Encapsulated61 class DvMultimedia < DvEncapsulated 62 62 attr_reader :media_type 63 63 attr_accessor :uri, :data, :compression_algorithm, … … 84 84 end 85 85 86 class D V_Parsable < DV_Encapsulated86 class DvParsable < DvEncapsulated 87 87 attr_reader :value, :formalism 88 88 def initialize(charset, language, size, formalism, value) … … 107 107 end 108 108 end # of Encapsulated 109 end # of Data _Types109 end # of DataTypes 110 110 end # of RM 111 111 end # of OpenEHR -
ruby/branches/0.5.0/lib/open_ehr/rm/data_types/quantity.rb
r149 r167 3 3 # Ticket refs #50 4 4 require 'assumed_library_types' 5 module OpenE HR5 module OpenEhr 6 6 module RM 7 module Data _Types7 module DataTypes 8 8 module Quantity 9 9 10 10 autoload :Date_Time, "rm/data_types/quantity/date_time.rb" 11 11 12 class D V_Ordered < OpenEHR::RM::Data_Types::Basic::Data_Value12 class DvOrdered < OpenEhr::RM::DataTypes::Basic::DataValue 13 13 include Comparable 14 14 attr_accessor :normal_range, :other_refference_ranges, :normal_status … … 51 51 end 52 52 53 class D V_Interval < OpenEHR::Assumed_Library_Types::Interval54 55 end 56 57 class D V_Quantified < DV_Ordered53 class DvInterval < OpenEhr::AssumedLibraryTypes::Interval 54 55 end 56 57 class DvQuantified < DvOrdered 58 58 attr_reader :magnitude, :magnitude_status 59 59 … … 78 78 if magnitude_status.nil? 79 79 @magnitude_status = '=' 80 elsif D V_Quantified.valid_magnitude_status?(magnitude_status)80 elsif DvQuantified.valid_magnitude_status?(magnitude_status) 81 81 @magnitude_status = magnitude_status 82 82 else … … 99 99 end 100 100 101 class D V_Ordinal < DV_Ordered101 class DvOrdinal < DvOrdered 102 102 attr_reader :value, :symbol, :limits 103 103 … … 121 121 122 122 def is_strictly_comparable_to?(others) 123 unless others.instance_of? OpenE HR::RM::Data_Types::Quantity::DV_Ordinal123 unless others.instance_of? OpenEhr::RM::DataTypes::Quantity::DvOrdinal 124 124 return false 125 125 end … … 144 144 end 145 145 146 class D V_Absolute_Quantity < DV_Quantified146 class DvAbsoluteQuantity < DvQuantified 147 147 attr_accessor :accuracy 148 148 … … 168 168 end 169 169 170 class D V_Amount < DV_Quantified170 class DvAmount < DvQuantified 171 171 attr_reader :accuracy, :accuracy_percent 172 172 def initialize(magnitude, magnitude_status=nil, accuracy=nil, … … 186 186 raise ArgumentError, 'type mismatch' 187 187 end 188 return D V_Amount.new(@magnitude+other.magnitude, @magnitude_status,188 return DvAmount.new(@magnitude+other.magnitude, @magnitude_status, 189 189 @accuracy, @accuracy_percent, @normal_range, 190 190 @normal_status, @other_reference_ranges) … … 210 210 end 211 211 212 class D V_Quantity < DV_Amount212 class DvQuantity < DvAmount 213 213 attr_reader :units, :precision 214 214 def initialize(magnitude, units, magnitude_status=nil, precision=nil, … … 235 235 def is_strictly_comparable_to?(others) 236 236 return false if others.nil? 237 if others.instance_of?(D V_Quantity) && others.units == @units237 if others.instance_of?(DvQuantity) && others.units == @units 238 238 return true 239 239 else … … 252 252 def +(other) 253 253 dv_amount = super(other) 254 return D V_Quantity.new(dv_amount.magnitude, @units,254 return DvQuantity.new(dv_amount.magnitude, @units, 255 255 @magnitude_status, @precision, 256 256 @accuracy, @accuracy_percent, @normal_range, … … 259 259 end 260 260 261 class D V_Count < DV_Amount261 class DvCount < DvAmount 262 262 def is_strictly_comparable_to?(others) 263 263 return false if others.nil? 264 if others.instance_of?(D V_Count)264 if others.instance_of?(DvCount) 265 265 return true 266 266 else … … 270 270 end 271 271 272 class Reference _Range272 class ReferenceRange 273 273 attr_reader :meaning, :range 274 274 … … 297 297 end 298 298 299 module Proportion _Kind299 module ProportionKind 300 300 PK_RATIO = 0 301 301 PK_UNITARY = 1 … … 304 304 PK_INTEGER_FRACTION = 4 305 305 306 def Proportion _Kind.valid_proportion_kind?(kind)306 def ProportionKind.valid_proportion_kind?(kind) 307 307 return true if kind >= 0 && kind <= 4 308 308 return false 309 309 end 310 end # end of Proportion _Kind311 312 class D V_Proportion < DV_Amount313 include Proportion _Kind310 end # end of ProportionKind 311 312 class DvProportion < DvAmount 313 include ProportionKind 314 314 attr_reader :numerator, :denominator, :type, :precision 315 315 … … 360 360 361 361 def type=(type) 362 if Proportion _Kind.valid_proportion_kind?(type)362 if ProportionKind.valid_proportion_kind?(type) 363 363 @type = type 364 364 else … … 386 386 387 387 def is_strictly_comparable_to?(other) 388 unless other.instance_of?(D V_Proportion)388 unless other.instance_of?(DvProportion) 389 389 return false 390 390 end … … 395 395 end 396 396 end 397 end # end of DV_Proportion 398 397 end # end of DvProportion 399 398 end # of Quantity 400 399 end # of Data_Types -
ruby/branches/0.5.0/lib/open_ehr/rm/data_types/quantity/date_time.rb
r157 r167 5 5 require 'date' 6 6 7 module OpenE HR7 module OpenEhr 8 8 module RM 9 module Data _Types9 module DataTypes 10 10 module Quantity 11 module Date _Time12 class D V_Temporal < OpenEHR::RM::Data_Types::Quantity::DV_Absolute_Quantity11 module DateTime 12 class DvTemporal < OpenEhr::RM::DataTypes::Quantity::DvAbsoluteQuantity 13 13 include Comparable 14 14 attr_reader :value … … 37 37 end 38 38 39 class D V_Date < DV_Temporal40 include OpenE HR::Assumed_Library_Types::ISO8601_DATE_MODULE39 class DvDate < DvTemporal 40 include OpenEhr::AssumedLibraryTypes::ISO8601_DATE_MODULE 41 41 42 42 DAYS_IN_MONTH = [0,31,28,31,30,31,30,31,31,30,31,30,31] … … 51 51 def value=(value) 52 52 super(value) 53 iso8601_date = Assumed _Library_Types::ISO8601_DATE.new(value)53 iso8601_date = AssumedLibraryTypes::ISO8601_DATE.new(value) 54 54 @year = iso8601_date.year 55 55 @month = iso8601_date.month … … 91 91 end 92 92 year += future.year - past.year 93 return D V_Duration.new(93 return DvDuration.new( 94 94 'P' + year.to_s + 'Y' + month.to_s + 'M' + 95 95 week.to_s + 'W' + day.to_s + 'D') … … 97 97 end 98 98 99 class D V_Time < DV_Temporal100 include OpenE HR::Assumed_Library_Types::ISO8601_TIME_MODULE99 class DvTime < DvTemporal 100 include OpenEhr::AssumedLibraryTypes::ISO8601_TIME_MODULE 101 101 def initialize(value, magnitude_status=nil, accuracy=nil, 102 102 normal_range=nil, normal_status=nil, … … 108 108 def value=(value) 109 109 super(value) 110 iso8601_time = Assumed _Library_Types::ISO8601_TIME.new(value)110 iso8601_time = AssumedLibraryTypes::ISO8601_TIME.new(value) 111 111 @hour = iso8601_time.hour 112 112 @minute = iso8601_time.minute … … 125 125 second = (diff - hour * 60 *60 - minute * 60).to_i 126 126 fractional_second = ((diff - diff.to_i)*1000000.0).to_i/1000000.0 127 return D V_Duration.new('P0Y0M0W0DT' + hour.to_s + 'H' +127 return DvDuration.new('P0Y0M0W0DT' + hour.to_s + 'H' + 128 128 minute.to_s + 'M' + 129 129 second.to_s + fractional_second.to_s[1..-1] + 'S') … … 131 131 end 132 132 133 class D V_Date_Time < DV_Temporal134 include OpenE HR::Assumed_Library_Types::ISO8601_DATE_TIME_MODULE133 class DvDateTime < DvTemporal 134 include OpenEhr::AssumedLibraryTypes::ISO8601_DATE_TIME_MODULE 135 135 attr_reader :value 136 136 … … 144 144 def value=(value) 145 145 super(value) 146 iso8601date_time = Assumed _Library_Types::ISO8601_DATE_TIME.new(value)146 iso8601date_time = AssumedLibraryTypes::ISO8601_DATE_TIME.new(value) 147 147 self.year = iso8601date_time.year 148 148 self.month = iso8601date_time.month … … 186 186 fractional_second = ((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0 187 187 188 return D V_Duration.new(date_duration.value + 'T' +188 return DvDuration.new(date_duration.value + 'T' + 189 189 hour.to_s + 'H' + 190 190 minute.to_s + 'M' + … … 197 197 def split_date_time(date_time) 198 198 /^(.*)T(.*)$/ =~ date_time.as_string 199 return D V_Date.new($1), DV_Time.new($2)200 end 201 end 202 203 class D V_Duration < DV_Amount204 include Assumed _Library_Types::ISO8601_DURATION_MODULE199 return DvDate.new($1), DvTime.new($2) 200 end 201 end 202 203 class DvDuration < DvAmount 204 include AssumedLibraryTypes::ISO8601_DURATION_MODULE 205 205 attr_reader :value 206 206 … … 214 214 raise ArgumentError, 'value must be not nil' if value.nil? 215 215 @value = value 216 iso8601_duration = Assumed _Library_Types::ISO8601_DURATION.new(value)216 iso8601_duration = AssumedLibraryTypes::ISO8601_DURATION.new(value) 217 217 self.years = iso8601_duration.years 218 218 self.months = iso8601_duration.months … … 234 234 235 235 end 236 end # of Date _Time236 end # of DateTime 237 237 end # of Quantity 238 238 end # of Data_Types -
ruby/branches/0.5.0/lib/open_ehr/rm/data_types/text.rb
r124 r167 2 2 # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067605961_209522_3179Report.html 3 3 # Ticket refs #48 4 module OpenE HR4 module OpenEhr 5 5 module RM 6 module Data _Types6 module DataTypes 7 7 module Text 8 class Term _Mapping8 class TermMapping 9 9 attr_reader :match, :purpose, :target 10 10 def initialize(match, purpose, target) … … 26 26 match == '?' 27 27 end 28 def Term _Mapping.is_valid_mach_code?(c)28 def TermMapping.is_valid_mach_code?(c) 29 29 c == '>' or c == '=' or c == '<' or c == '?' 30 30 end 31 31 private 32 32 def match_valid(match) 33 raise ArgumentError, "match is not valid" if !Term _Mapping.is_valid_mach_code? match33 raise ArgumentError, "match is not valid" if !TermMapping.is_valid_mach_code? match 34 34 end 35 35 def purpose_valid(purpose) 36 if purpose.nil? or !purpose.instance_of? D V_Coded_Text36 if purpose.nil? or !purpose.instance_of? DvCodedText 37 37 raise ArgumentError, "purpose is not valid" 38 38 end … … 44 44 end 45 45 46 class Code _Phrase46 class CodePhrase 47 47 attr_reader :terminology_id, :code_string 48 48 def initialize(code_string, terminology_id) … … 60 60 @code_string = code_string 61 61 end 62 end # of Code _Phrase62 end # of CodePhrase 63 63 64 class D V_Text < OpenEHR::RM::Data_Types::Basic::Data_Value64 class DvText < OpenEhr::RM::DataTypes::Basic::DataValue 65 65 attr_reader :value, :formatting, :hyperlink, :mappings 66 66 attr_reader :language, :encoding … … 68 68 mappings = nil, language = nil, encoding = nil) 69 69 value_valid(value) 70 D V_Text.formatting_valid(formatting)71 D V_Text.encoding_valid(encoding)72 D V_Text.mapping_valid(mappings)73 D V_Text.language_valid(language)70 DvText.formatting_valid(formatting) 71 DvText.encoding_valid(encoding) 72 DvText.mapping_valid(mappings) 73 DvText.language_valid(language) 74 74 @value, @formatting, @encoding = value, formatting, encoding 75 75 @mappings, @language = mappings, language … … 80 80 end 81 81 def formatting=(formatting) 82 D V_Text.formatting_valid(formatting)82 DvText.formatting_valid(formatting) 83 83 @formatting = formatting 84 84 end 85 85 def encoding=(encoding) 86 D V_Text.encoding_valid(encoding)86 DvText.encoding_valid(encoding) 87 87 @encoding = encoding 88 88 end 89 89 def mappings=(mappings) 90 D V_Text.mapping_valid(mappings)90 DvText.mapping_valid(mappings) 91 91 @mappings = mappings 92 92 end 93 93 def language=(language) 94 D V_Text.language_valid(language)94 DvText.language_valid(language) 95 95 @language = language 96 96 end … … 99 99 if value.nil? or value.empty? or value.include? CR or value.include? LF 100 100 raise ArgumentError, "value is not valid" 101 # CR and LF are defined in Basic_Definition inherited Data _Value.101 # CR and LF are defined in Basic_Definition inherited DataValue. 102 102 end 103 103 end … … 128 128 end 129 129 130 class D V_Coded_Text < DV_Text130 class DvCodedText < DvText 131 131 attr_reader :defining_code 132 132 … … 146 146 end 147 147 148 class D V_Paragraph < OpenEHR::RM::Data_Types::Basic::Data_Value148 class DvParagraph < OpenEhr::RM::DataTypes::Basic::DataValue 149 149 attr_reader :items 150 150 def initialize(items) … … 167 167 168 168 end # of Text 169 end # of Data _Type169 end # of DataTypes 170 170 end # of RM 171 171 end # of OpenEHR -
ruby/branches/0.5.0/lib/open_ehr/rm/data_types/time_specification.rb
r153 r167 1 1 # This module is related to the ticket #47 2 2 3 module OpenE HR3 module OpenEhr 4 4 module RM 5 module Data _Types6 module Time _Specification7 class D V_Time_Specification < OpenEHR::RM::Data_Types::Basic::Data_Value5 module DataTypes 6 module TimeSpecification 7 class DvTimeSpecification < OpenEhr::RM::DataTypes::Basic::DataValue 8 8 attr_reader :value 9 9 … … 34 34 35 35 36 class D V_General_Time_Specification < DV_Time_Specification36 class DvGeneralTimeSpecification < DvTimeSpecification 37 37 attr_reader :value 38 38 def initialize(value) … … 48 48 end 49 49 50 class D V_Periodic_Time_Specification < DV_Time_Specification50 class DvPeriodicTimeSpecification < DvTimeSpecification 51 51 attr_reader :value, :calender_alignment, :event_alingment, :period 52 52 def initialize(value) -
ruby/branches/0.5.0/lib/open_ehr/rm/data_types/uri.rb
r104 r167 5 5 require 'uri' 6 6 #require 'uri/generic' 7 module U RI8 class E HR< ::URI::Generic7 module Uri 8 class Ehr < ::URI::Generic 9 9 COMPONENT = [ 10 10 :scheme, :path, :fragment, :query … … 21 21 end 22 22 end 23 @@schemes['EHR'] = E HR23 @@schemes['EHR'] = Ehr 24 24 end 25 25 26 module OpenE HR26 module OpenEhr 27 27 module RM 28 module Data _Types29 module U RI30 class D V_URI < OpenEHR::RM::Data_Types::Basic::Data_Value28 module DataTypes 29 module Uri 30 class DvUri < OpenEhr::RM::DataTypes::Basic::DataValue 31 31 def initialize(value) 32 32 self.value = value … … 57 57 end 58 58 59 class D V_EHR_URI < DV_URI59 class DvEhrUri < DvUri 60 60 def initialize(value) 61 61 super(value) … … 67 67 end # of DV_EHR_URI 68 68 end # of URI 69 end # of Data _Type69 end # of DataTypes 70 70 end # of RM 71 71 end # of OpenEHR
Note:
See TracChangeset
for help on using the changeset viewer.