Changeset 51


Ignore:
Timestamp:
May 12, 2008, 11:48:37 PM (14 years ago)
Author:
KOBAYASHI, Shinji
Message:

worked on demographic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/models/rm/demographic.rb

    r10 r51  
    22  module RM
    33    module Demogrphic
    4       class Party < OpenEHR::RM::Common::Archetyped::Locatable
     4      # this class is based on the UML,
     5      # http://www.openehr.org/svn/specification/TAGS/Release-1.0.1/publishing/architecture/computable/UML/uml_start_view.html
     6      class PARTY < OpenEHR::RM::Common::Archetyped::Locatable
    57        attr_reader :details, :reverse_relationships, :uid
    68        attr_reader :idetities, :contacts, :relationships
     
    1921        end
    2022        def type
    21          
     23          return name
    2224        end
    2325        def uid=(uid)
     
    5456        end
    5557      end
    56       class Actor < Party
    57        
     58      class ACTOR < PARTY
     59        LEAGAL_IDENTITY = 'leagal identity'
     60        attr_reader :languages, :rules
     61        def initialize(uid, archetype_node_id, name, archetype_details,
     62                       feeder_audit, links, identities, contacts,
     63                       relationships, reverse_relationships, details,
     64                       languages, rules)
     65          super(uid, archetype_node_id, name, archetype_details,
     66                feeder_audit, links, relationships, reverse_relationships,
     67                details)
     68          has_legal_identity?
     69          set_languages(languages)
     70          set_rules(rules)
     71        end
     72        def has_legal_identity?
     73          @identities.each {|identity|
     74            if (identity.purpose.value == LEAGAL_IDENTITY)
     75              return true
     76            end
     77          }
     78          false
     79        end
     80        def languages=(languages)
     81          set_languages(languages)
     82        end
     83        def values=(values)
     84          set_values(values)
     85        end
     86        private
     87        def set_languages(languages)
     88          if languages.nil?
     89            raise ArgumentError, "languages should not be nil."
     90          elsif languages.empty?
     91            raise ArgumentError, "languages shouldnot be empty."
     92          end
     93          @languages = languages
     94        end
     95        def set_values(values)
     96          if values.nil?
     97            raise ArgumentError, "values should not be nil."
     98          elsif values.empty?
     99            raise ArgumentError, "values should not be nil."
     100          end
     101          @values = values
     102      end
     103      class CONTACT < OpenEHR::RM::Common::Archetyped::Locatable
     104        attr_accessor :time_validity
     105        attr_reader :addresses
     106        def initialize(uid, archetype_node_id, name, archetype_details,
     107                       feeder_audit, links, parent, time_validity, addresses)
     108          super(uid, archetype_node_id, name, archetype_details,
     109                feeder_audit, links, parent)
     110          address_exists?(addresses)
     111          @addresses = addresses
     112          @time_validity = time_validity
     113        end
     114        def purpose
     115          @name
     116        end
     117        def purpose=(purpose)
     118          @name = purpose
     119        end
     120        def addresses=(addresses)
     121          address_exists?(addresses)
     122          @addresses = addresses
     123        end
     124        private
     125        def address_exists?(addresses)
     126          if addresses.nil?
     127            raise ArgumentError, "address must not be nil"
     128          elsif addresses.empty?
     129            raise ArgumentError, "address must not be empty"
     130          end
     131        end
    58132      end
    59133    end # of Demographic
Note: See TracChangeset for help on using the changeset viewer.