Changeset 361


Ignore:
Timestamp:
Nov 19, 2009, 11:32:47 PM (10 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #45 Party

Location:
ruby/branches/0.5
Files:
1 added
1 edited

Legend:

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

    r167 r361  
    22# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_76d0249_1118674798473_6021_0Report.html
    33# Ticket refs #45
     4include OpenEHR::RM::Common::Archetyped
     5
    46module OpenEHR
    57  module RM
    6     module Demogrphic
    7       class Address < OpenEHR::RM::Common::Archetyped::Locatable
     8    module Demographic
     9      class Address < Locatable
    810        attr_reader :details
    911
     
    1719      end
    1820
    19       class Capability < OpenEHR::RM::Common::Archetyped::Locatable
     21      class Capability < Locatable
    2022        attr_reader :credentials, :time_validity
    2123
    2224      end
    2325
    24       class Party < OpenEHR::RM::Common::Archetyped::Locatable
    25         attr_reader :details, :reverse_relationships, :uid
    26         attr_reader :idetities, :contacts, :relationships
    27         def initialize(uid, archetype_node_id, name, archetype_details,
    28                        feeder_audit, links, identities, contacts,
    29                        relationships, reverse_relationships, details)
    30           super(uid, archetype_node_id, name, archetype_details,
    31                 feeder_audit, links, nil)
    32           uid_valid(uid)
     26      class Party < Locatable
     27        attr_reader :uid, :identities, :contacts, :relationships,
     28                    :reverse_relationships
     29        attr_accessor :details
     30        alias :type :name
     31
     32        def initialize(args = { })
     33          super(args)
     34          self.uid = args[:uid]
     35          self.identities = args[:identities]
     36          self.contacts = args[:contacts]
     37          self.relationships = args[:relationships]
     38          self.reverse_relationships =
     39            args[:reverse_relationships]
     40          self.details = args[:details]
     41        end
     42
     43        def uid=(uid)
     44          raise ArgumentError, 'uid is mandatory' if uid.nil?
    3345          @uid = uid
    34           identities_vaild(identities)
     46        end
     47
     48        def identities=(identities)
     49          if identities.nil? || identities.empty?
     50            raise ArgumentError, 'identities are mandatory'
     51          end
    3552          @identities = identities
    36           contacts_valid(contacts)
     53        end
     54
     55        def contacts=(contacts)
     56          if !contacts.nil? && contacts.empty?
     57            raise ArgumentError, 'contacts should not be empty'
     58          end
    3759          @contacts = contacts
    38           relationships_valid(relationships)
    39         end
    40         def type
    41           return name
    42         end
    43         def uid=(uid)
    44           uid_valid(uid)
    45           @uid = uid
    46         end
    47         def identities=(identities)
    48           identities_vaild(identities)
    49           @identities = identities
    50         def contacts=(contacts)
    51           contacts_valid(contacts)
    52           @contacts = contacts
    53         end
     60        end
     61
    5462        def parent=(parent)
    5563          @parent = nil
    5664        end
    57         private
    58         def uid_valid(uid)
    59           raise ArgumentError, "uid is not valid" if uid.nil?
    60         end
    61         def identities_vaild(identities)
    62           if identities.nil?
    63             raise ArgumentError, "identities must not be nil"
    64           elsif identities.empty?
    65             raise ArgumentError, "identities must not be empty"
    66           end
    67         end
    68         def contacts_valid(contacts)
    69           if contacs.nil?
    70             raise ArgumentError, "contacts must not be nil"
    71           elsif contacts.empty?
    72             raise ArgumentError, "contacts must not be empty"
    73           end         
    74         end
    75       end
    76 
    77       class PartyIdentity < OpenEHR::RM::Common::Archetyped::Locatable
     65
     66        def relationships=(relationships)
     67          unless relationships.nil?
     68            if relationships.empty?
     69              raise ArgumentError, 'relationships should not be empty?'
     70            else
     71              relationships.each do |rel|
     72                if rel.source.id.value != @uid.value
     73                  raise ArgumentError, 'invalid source of relationships'
     74                end
     75              end
     76            end
     77          end
     78          @relationships = relationships
     79        end
     80
     81        def reverse_relationships=(reverse_relationships)
     82          if !reverse_relationships.nil? && reverse_relationships.empty?
     83            raise ArgumentError, 'reverse_relationships should not be empty'
     84          end
     85          @reverse_relationships = reverse_relationships
     86        end
     87      end
     88
     89      class PartyIdentity < Locatable
    7890        attr_reader :details
    7991
    8092      end
    8193
    82       class PartyRelationship < OpenEHR::RM::Common::Archetyped::Locatable
    83 
    84       end
    85 
    86       class Versioned_Party < OpenEHR::RM::Common::Archetyped::Locatable
     94      class PartyRelationship < Locatable
     95
     96      end
     97
     98      class VersionedParty < Locatable
    8799
    88100      end
     
    95107        LEAGAL_IDENTITY = 'leagal identity'
    96108        attr_reader :languages, :rules
     109
    97110        def initialize(uid, archetype_node_id, name, archetype_details,
    98111                       feeder_audit, links, identities, contacts,
     
    106119          set_rules(rules)
    107120        end
     121
    108122        def has_legal_identity?
    109123          @identities.each {|identity|
     
    114128          false
    115129        end
     130
    116131        def languages=(languages)
    117132          set_languages(languages)
    118133        end
     134
    119135        def values=(values)
    120136          set_values(values)
     
    129145          @languages = languages
    130146        end
     147
    131148        def set_values(values)
    132149          if values.nil?
     
    136153          end
    137154          @values = values
    138       end
    139       class Contact < OpenEHR::RM::Common::Archetyped::Locatable
     155        end
     156      end
     157
     158      class Contact < Locatable
    140159        attr_accessor :time_validity
    141160        attr_reader :addresses
     
    148167          @time_validity = time_validity
    149168        end
     169
    150170        def purpose
    151171          @name
    152172        end
     173
    153174        def purpose=(purpose)
    154175          @name = purpose
    155176        end
     177
    156178        def addresses=(addresses)
    157179          address_exists?(addresses)
     
    159181        end
    160182        private
     183
    161184        def address_exists?(addresses)
    162185          if addresses.nil?
Note: See TracChangeset for help on using the changeset viewer.