[86] | 1 | # This module is based on the UML,
|
---|
| 2 | # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_76d0249_1118674798473_6021_0Report.html
|
---|
| 3 | # Ticket refs #45
|
---|
[6] | 4 | module OpenEHR
|
---|
| 5 | module RM
|
---|
| 6 | module Demogrphic
|
---|
[87] | 7 | class Address < OpenEHR::RM::Common::Archetyped::Locatable
|
---|
| 8 | attr_reader :details
|
---|
| 9 |
|
---|
| 10 | def as_string
|
---|
| 11 |
|
---|
| 12 | end
|
---|
| 13 |
|
---|
| 14 | def type
|
---|
| 15 |
|
---|
| 16 | end
|
---|
| 17 | end
|
---|
| 18 |
|
---|
| 19 | class Capability < OpenEHR::RM::Common::Archetyped::Locatable
|
---|
| 20 | attr_reader :credentials, :time_validity
|
---|
| 21 |
|
---|
| 22 | end
|
---|
| 23 |
|
---|
[86] | 24 | class Party < OpenEHR::RM::Common::Archetyped::Locatable
|
---|
[7] | 25 | attr_reader :details, :reverse_relationships, :uid
|
---|
| 26 | attr_reader :idetities, :contacts, :relationships
|
---|
[8] | 27 | def initialize(uid, archetype_node_id, name, archetype_details,
|
---|
[9] | 28 | feeder_audit, links, identities, contacts,
|
---|
| 29 | relationships, reverse_relationships, details)
|
---|
[8] | 30 | super(uid, archetype_node_id, name, archetype_details,
|
---|
| 31 | feeder_audit, links, nil)
|
---|
| 32 | uid_valid(uid)
|
---|
| 33 | @uid = uid
|
---|
[9] | 34 | identities_vaild(identities)
|
---|
| 35 | @identities = identities
|
---|
| 36 | contacts_valid(contacts)
|
---|
| 37 | @contacts = contacts
|
---|
| 38 | relationships_valid(relationships)
|
---|
[8] | 39 | end
|
---|
[7] | 40 | def type
|
---|
[51] | 41 | return name
|
---|
[7] | 42 | end
|
---|
[9] | 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
|
---|
[8] | 54 | def parent=(parent)
|
---|
| 55 | @parent = nil
|
---|
| 56 | end
|
---|
| 57 | private
|
---|
| 58 | def uid_valid(uid)
|
---|
| 59 | raise ArgumentError, "uid is not valid" if uid.nil?
|
---|
| 60 | end
|
---|
[9] | 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
|
---|
[7] | 75 | end
|
---|
[87] | 76 |
|
---|
| 77 | class Party_Identity < OpenEHR::RM::Common::Archetyped::Locatable
|
---|
| 78 | attr_reader :details
|
---|
| 79 |
|
---|
| 80 | end
|
---|
| 81 |
|
---|
| 82 | class Party_Relationship < OpenEHR::RM::Common::Archetyped::Locatable
|
---|
| 83 |
|
---|
| 84 | end
|
---|
| 85 |
|
---|
| 86 | class Versioned_Party < OpenEHR::RM::Common::Archetyped::Locatable
|
---|
| 87 |
|
---|
| 88 | end
|
---|
| 89 |
|
---|
| 90 | class Role < Party
|
---|
| 91 |
|
---|
| 92 | end
|
---|
| 93 |
|
---|
[86] | 94 | class Actor < Party
|
---|
[51] | 95 | LEAGAL_IDENTITY = 'leagal identity'
|
---|
| 96 | attr_reader :languages, :rules
|
---|
| 97 | def initialize(uid, archetype_node_id, name, archetype_details,
|
---|
| 98 | feeder_audit, links, identities, contacts,
|
---|
| 99 | relationships, reverse_relationships, details,
|
---|
| 100 | languages, rules)
|
---|
| 101 | super(uid, archetype_node_id, name, archetype_details,
|
---|
| 102 | feeder_audit, links, relationships, reverse_relationships,
|
---|
| 103 | details)
|
---|
| 104 | has_legal_identity?
|
---|
| 105 | set_languages(languages)
|
---|
| 106 | set_rules(rules)
|
---|
| 107 | end
|
---|
| 108 | def has_legal_identity?
|
---|
| 109 | @identities.each {|identity|
|
---|
| 110 | if (identity.purpose.value == LEAGAL_IDENTITY)
|
---|
| 111 | return true
|
---|
| 112 | end
|
---|
| 113 | }
|
---|
| 114 | false
|
---|
| 115 | end
|
---|
| 116 | def languages=(languages)
|
---|
| 117 | set_languages(languages)
|
---|
| 118 | end
|
---|
| 119 | def values=(values)
|
---|
| 120 | set_values(values)
|
---|
| 121 | end
|
---|
| 122 | private
|
---|
| 123 | def set_languages(languages)
|
---|
| 124 | if languages.nil?
|
---|
| 125 | raise ArgumentError, "languages should not be nil."
|
---|
| 126 | elsif languages.empty?
|
---|
| 127 | raise ArgumentError, "languages shouldnot be empty."
|
---|
| 128 | end
|
---|
| 129 | @languages = languages
|
---|
| 130 | end
|
---|
| 131 | def set_values(values)
|
---|
| 132 | if values.nil?
|
---|
| 133 | raise ArgumentError, "values should not be nil."
|
---|
| 134 | elsif values.empty?
|
---|
| 135 | raise ArgumentError, "values should not be nil."
|
---|
| 136 | end
|
---|
| 137 | @values = values
|
---|
[10] | 138 | end
|
---|
[86] | 139 | class Contact < OpenEHR::RM::Common::Archetyped::Locatable
|
---|
[51] | 140 | attr_accessor :time_validity
|
---|
| 141 | attr_reader :addresses
|
---|
| 142 | def initialize(uid, archetype_node_id, name, archetype_details,
|
---|
| 143 | feeder_audit, links, parent, time_validity, addresses)
|
---|
| 144 | super(uid, archetype_node_id, name, archetype_details,
|
---|
| 145 | feeder_audit, links, parent)
|
---|
| 146 | address_exists?(addresses)
|
---|
| 147 | @addresses = addresses
|
---|
| 148 | @time_validity = time_validity
|
---|
| 149 | end
|
---|
| 150 | def purpose
|
---|
| 151 | @name
|
---|
| 152 | end
|
---|
| 153 | def purpose=(purpose)
|
---|
| 154 | @name = purpose
|
---|
| 155 | end
|
---|
| 156 | def addresses=(addresses)
|
---|
| 157 | address_exists?(addresses)
|
---|
| 158 | @addresses = addresses
|
---|
| 159 | end
|
---|
| 160 | private
|
---|
| 161 | def address_exists?(addresses)
|
---|
| 162 | if addresses.nil?
|
---|
| 163 | raise ArgumentError, "address must not be nil"
|
---|
| 164 | elsif addresses.empty?
|
---|
| 165 | raise ArgumentError, "address must not be empty"
|
---|
| 166 | end
|
---|
| 167 | end
|
---|
| 168 | end
|
---|
[86] | 169 |
|
---|
| 170 | class Agent < Actor
|
---|
| 171 |
|
---|
| 172 | end
|
---|
| 173 |
|
---|
| 174 | class Organisation < Actor
|
---|
| 175 |
|
---|
| 176 | end
|
---|
| 177 |
|
---|
| 178 | class Person < Actor
|
---|
| 179 |
|
---|
| 180 | end
|
---|
| 181 |
|
---|
| 182 | class Group < Actor
|
---|
| 183 |
|
---|
| 184 | end
|
---|
[6] | 185 | end # of Demographic
|
---|
| 186 | end # of RM
|
---|
| 187 | end # of OpenEHR
|
---|