Changeset 226 for ruby/branches/0.5/lib
- Timestamp:
- Aug 27, 2009, 10:47:01 PM (15 years ago)
- Location:
- ruby/branches/0.5/lib/open_ehr/rm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb
r224 r226 10 10 class TermMapping 11 11 attr_reader :match, :purpose, :target 12 def initialize(match, purpose, target) 13 match_valid(match)14 purpose_valid(purpose)15 target_valid(target)16 @match, @purpose, @target = match, purpose, target12 13 def initialize(args ={}) 14 self.match = args[:match] 15 self.purpose = args[:purpose] 16 self.target = args[:target] 17 17 end 18 19 def match=(match) 20 unless TermMapping.is_valid_mach_code? match 21 raise ArgumentError, 'invalid match character' 22 end 23 @match = match 24 end 25 26 def purpose=(purpose) 27 # if !purpose.nil? and !purpose.instance_of?(DvCodedText) 28 # raise ArgumentError, "purpose is not valid" 29 # end 30 # should be settled after terminology service implemented 31 @purpose = purpose 32 end 33 34 def target=(target) 35 raise ArgumentError, "target must not be nil" if target.nil? 36 @target = target 37 end 38 18 39 def broader? 19 40 match == '>' 20 41 end 42 21 43 def equivalent? 22 44 match == '=' 23 45 end 46 24 47 def narrower? 25 48 match == '<' 26 49 end 50 27 51 def unknown? 28 52 match == '?' 29 53 end 54 30 55 def TermMapping.is_valid_mach_code?(c) 31 56 c == '>' or c == '=' or c == '<' or c == '?' 32 end33 private34 def match_valid(match)35 raise ArgumentError, "match is not valid" if !TermMapping.is_valid_mach_code? match36 end37 def purpose_valid(purpose)38 if purpose.nil? or !purpose.instance_of? DvCodedText39 raise ArgumentError, "purpose is not valid"40 end41 # should be settled after terminology service implemented42 end43 def target_valid(target)44 raise ArgumentError, "target must not be nil" if target.nil?45 57 end 46 58 end -
ruby/branches/0.5/lib/open_ehr/rm/support/terminology.rb
r216 r226 8 8 raise NotImplementedError, "all_codes must be implemented" 9 9 end 10 10 11 def has_code(a_code) 11 12 raise NotImplementedError, "has_code must be implemented" 12 13 end 14 13 15 def has_lang(a_lang) 14 16 raise NotImplementedError, "has_lang must be implemented" 15 17 end 18 16 19 def id 17 20 raise NotImplementedError, "id must be returned" 18 21 end 19 22 end 23 20 24 module OpenEHRCodeSetIdentifier 21 25 CODE_SET_ID_CHARACER_SETS = "character sets".freeze … … 29 33 end 30 34 end 35 31 36 module OpenEHRTerminologyGroupIdentifiers 32 37 GROUP_ID_ATTESTATION_REASON = "attestation reason".freeze … … 46 51 TERMINOLOGY_ID = "openehr".freeze 47 52 end 53 48 54 class TerminologyAccess 55 attr_reader :id 56 57 def initialize(args = {}) 58 self.id = args[:id] 59 end 60 49 61 def all_codes 50 62 raise NotImplementedError, "all_codes is not implemented" 51 63 end 64 52 65 def codes_for_group_id(group_id) 53 66 raise NotImplementedError, "codes_for_group_id is not implemented" 54 67 end 68 55 69 def codes_for_group_name(name, lang) 56 70 raise NotImplementedError, "codes_for_group_name is not implemented" 57 71 end 72 58 73 def has_code_for_group_id(group_id, a_code) 59 raise NotImplementedError, "has_code_for_group_id is not implemented"74 60 75 end 61 def id 62 raise NotImplementedError, "id is not implemented" 76 77 def id=(id) 78 @terminology = Terminology.find_all_by_name(id) 79 @id = id 63 80 end 81 64 82 def rubric_for_code(code, lang) 65 raise NotImplementedError, "rubic_for_code is not implemented" 83 return Terminology.find(:first, :conditions => {:code => code, 84 :lang => lang}) 66 85 end 86 67 87 private 68 88 def id_exists … … 74 94 end 75 95 end 96 76 97 class TerminologyService 77 98 include OpenEHRCodeSetIdentifier, OpenEHRTerminologyGroupIdentifiers 99 78 100 def code_set(name) 79 101 raise NotImplementedError, "code_set is not implemented" 80 102 end 103 81 104 def code_set_for_id(id) 82 105 raise NotImplementedError, "code_set_for_id is not implemented" 83 106 end 107 84 108 def code_set_identifiers 85 109 raise NotImplementedError, "code_set_for_identifiers is not implemented" 86 110 end 111 87 112 def has_code_set(name) 88 113 raise NotImplementedError, "has_code_set is not implemented" 89 114 end 115 90 116 def has_terminology?(name) 91 117 raise NotImplementedError, "has_terminology is not implemented" 92 118 end 119 93 120 def openehr_code_sets 94 121 raise NotImplementedError, "openehr_code_set is not implemented" 95 122 end 123 96 124 def terminology(name) 97 r aise NotImplementedError, "terminology is not implemented"125 return TerminologyAccess.new(:id => name) 98 126 end 127 99 128 def terminology_identifiers 100 129 raise NotImplementedError, "terminology_identiferes is not implemented"
Note:
See TracChangeset
for help on using the changeset viewer.