Changeset 226


Ignore:
Timestamp:
Aug 27, 2009, 10:47:01 PM (11 years ago)
Author:
KOBAYASHI, Shinji
Message:

moving to Rspec

Location:
ruby/branches/0.5
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb

    r224 r226  
    1010        class TermMapping
    1111          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, target
     12
     13          def initialize(args ={})
     14            self.match = args[:match]
     15            self.purpose = args[:purpose]
     16            self.target = args[:target]
    1717          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
    1839          def broader?
    1940            match == '>'
    2041          end
     42
    2143          def equivalent?
    2244            match == '='
    2345          end
     46
    2447          def narrower?
    2548            match == '<'
    2649          end
     50
    2751          def unknown?
    2852            match == '?'
    2953          end
     54
    3055          def TermMapping.is_valid_mach_code?(c)
    3156            c == '>' or c == '=' or c == '<' or c == '?'
    32           end
    33           private
    34           def match_valid(match)
    35             raise ArgumentError, "match is not valid" if !TermMapping.is_valid_mach_code? match
    36           end
    37           def purpose_valid(purpose)
    38             if purpose.nil? or !purpose.instance_of? DvCodedText
    39               raise ArgumentError, "purpose is not valid"
    40             end
    41             # should be settled after terminology service implemented
    42           end
    43           def target_valid(target)
    44             raise ArgumentError, "target must not be nil" if target.nil?
    4557          end
    4658        end
  • ruby/branches/0.5/lib/open_ehr/rm/support/terminology.rb

    r216 r226  
    88            raise NotImplementedError, "all_codes must be implemented"
    99          end
     10
    1011          def has_code(a_code)
    1112            raise NotImplementedError, "has_code must be implemented"
    1213          end
     14
    1315          def has_lang(a_lang)
    1416            raise NotImplementedError, "has_lang must be implemented"
    1517          end
     18
    1619          def id
    1720            raise NotImplementedError, "id must be returned"
    1821          end
    1922        end
     23
    2024        module OpenEHRCodeSetIdentifier
    2125          CODE_SET_ID_CHARACER_SETS = "character sets".freeze
     
    2933          end
    3034        end
     35
    3136        module OpenEHRTerminologyGroupIdentifiers
    3237          GROUP_ID_ATTESTATION_REASON = "attestation reason".freeze
     
    4651          TERMINOLOGY_ID = "openehr".freeze
    4752        end
     53
    4854        class TerminologyAccess
     55          attr_reader :id
     56
     57          def initialize(args = {})
     58            self.id = args[:id]
     59          end
     60
    4961          def all_codes
    5062            raise NotImplementedError, "all_codes is not implemented"
    5163          end
     64
    5265          def codes_for_group_id(group_id)
    5366            raise NotImplementedError, "codes_for_group_id is not implemented"
    5467          end
     68
    5569          def codes_for_group_name(name, lang)
    5670            raise NotImplementedError, "codes_for_group_name is not implemented"
    5771          end
     72
    5873          def has_code_for_group_id(group_id, a_code)
    59             raise NotImplementedError, "has_code_for_group_id is not implemented"
     74           
    6075          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
    6380          end
     81
    6482          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})
    6685          end
     86
    6787          private
    6888          def id_exists
     
    7494          end
    7595        end
     96
    7697        class TerminologyService
    7798          include OpenEHRCodeSetIdentifier, OpenEHRTerminologyGroupIdentifiers
     99
    78100          def code_set(name)
    79101            raise NotImplementedError, "code_set is not implemented"
    80102          end
     103
    81104          def code_set_for_id(id)
    82105            raise NotImplementedError, "code_set_for_id is not implemented"
    83106          end
     107
    84108          def code_set_identifiers
    85109            raise NotImplementedError, "code_set_for_identifiers is not implemented"
    86110          end
     111
    87112          def has_code_set(name)
    88113            raise NotImplementedError, "has_code_set is not implemented"
    89114          end
     115
    90116          def has_terminology?(name)
    91117            raise NotImplementedError, "has_terminology is not implemented"
    92118          end
     119
    93120          def openehr_code_sets
    94121            raise NotImplementedError, "openehr_code_set is not implemented"
    95122          end
     123
    96124          def terminology(name)
    97             raise NotImplementedError, "terminology is not implemented"
     125            return TerminologyAccess.new(:id => name)
    98126          end
     127         
    99128          def terminology_identifiers
    100129            raise NotImplementedError, "terminology_identiferes is not implemented"
Note: See TracChangeset for help on using the changeset viewer.